diff --git a/README.md b/README.md index 1490382..03b37fb 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ be found under the `__tests__` directory and run with `yarn run test`. ### Content updates Make your content changes to the `cms.data.js` file in the root of this -repository. +repository. In addition, you'll need to edit `siteMetadata.js` for proper SEO updating. > ℹ We are upgrading and standardizing the naming conventions so that they may be updated without examining the component codebase. ℹ diff --git a/package.json b/package.json index 26c9adf..e1c0e9f 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "localforage": "^1.10.0", "nanoid": "^3.2.0", "next-auth": "^4.1.2", + "next-seo": "^5.0.0", "nodemailer": "^6.7.2", "postcss": "^8.4.5", "prisma": "^3.8.1", diff --git a/pages/_app.jsx b/pages/_app.jsx index 5caec75..8b7d9f0 100644 --- a/pages/_app.jsx +++ b/pages/_app.jsx @@ -1,9 +1,12 @@ import "../styles/global.css"; import { SessionProvider } from "next-auth/react"; +import { DefaultSeo } from "next-seo"; +import { defaultSeoContent } from "../siteMetadata"; function MyApp({ Component, pageProps: { session, ...pageProps } }) { return ( + ); diff --git a/pages/index.jsx b/pages/index.jsx index 3352242..35d171a 100644 --- a/pages/index.jsx +++ b/pages/index.jsx @@ -1,7 +1,9 @@ import { useState, useRef, useEffect } from "react"; import { fetcher, clientJwtDecode } from "../lib/utils"; import { useSession, signIn, signOut } from "next-auth/react"; +import { routeSeoContent } from "../siteMetadata.js"; import localforage from "localforage"; +import { NextSeo } from "next-seo"; import useSwr, { mutate } from "swr"; import Footer from "../components/Footer"; import NavigationHero from "../components/Sections/NavigationHero"; @@ -141,6 +143,7 @@ export default function Funded() { name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> + diff --git a/siteMetadata.js b/siteMetadata.js new file mode 100644 index 0000000..059b4a9 --- /dev/null +++ b/siteMetadata.js @@ -0,0 +1,53 @@ +import {author, description, entityUrl, logoSrc, title} from './cms.data'; + +// https://github.com/garmeeh/next-seo#default-seo-configuration +export const defaultSeoContent = { + title : title, + description : description, + openGraph : { + type : 'website', + locale : 'en_IE', + url : entityUrl, + site_name : author, + }, + twitter : { + handle : '@handle', + site : '@site', + cardType : 'summary_large_image', + } +}; + +export const routeSeoContent = { + "/" : { + title : "Using More of Config", + description : "This example uses more of the available config options.", + canonical : "https://www.canonical.ie/", + openGraph : { + url : 'https://www.url.ie/a', + title : 'Open Graph Title', + description : 'Open Graph Description', + images : [ + { + url : logoSrc, + width : 800, + height : 600, + alt : author, + type : 'image/jpeg', + }, + { + url : logoSrc, + width : 900, + height : 800, + alt : author, + type : 'image/jpeg', + }, + ], + site_name : author, + }, + twitter : { + handle : '@tincre', + site : '@tincre', + cardType : 'summary_large_image', + } + } +}; diff --git a/yarn.lock b/yarn.lock index ea4f3a7..aea208a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3191,6 +3191,11 @@ next-auth@^4.1.2: preact-render-to-string "^5.1.19" uuid "^8.3.2" +next-seo@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/next-seo/-/next-seo-5.0.0.tgz#8a5c82279edcbd74c4ce58efa5588528e47c0d72" + integrity sha512-uCa8hoE5VQz4D2NqZAPhqR64hY5LSmaq70wmfGK09U57TMY7XzsDI+MjfZo0MgHJM87bj3Fd/oMQbDcZ/YWhJQ== + next@^12.0.9: version "12.0.9" resolved "https://registry.yarnpkg.com/next/-/next-12.0.9.tgz#4eb3006b63bb866f5c2918ca0003e98f4259e063"