From a84e5469785cca6d959cf3f2f5f9c00bb6b39ad7 Mon Sep 17 00:00:00 2001 From: Walidoux Date: Mon, 16 May 2022 13:25:22 +0100 Subject: [PATCH] fix: resolve bad SEO --- components/Head/NextHead.tsx | 29 ------------------- .../{Head/CommonHead.tsx => NextHead.tsx} | 26 +++++++++++++---- pages/_document.tsx | 6 ++-- 3 files changed, 22 insertions(+), 39 deletions(-) delete mode 100644 components/Head/NextHead.tsx rename components/{Head/CommonHead.tsx => NextHead.tsx} (77%) diff --git a/components/Head/NextHead.tsx b/components/Head/NextHead.tsx deleted file mode 100644 index f729405..0000000 --- a/components/Head/NextHead.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import Head from 'next/head' - -import { projectConfig } from 'utils/config' - -interface HeadProps { - longName?: string - shortName?: string -} - -const NextHead: React.FC = (props) => { - const { - longName = projectConfig.longName, - shortName = projectConfig.shortName - } = props - - return ( - - - {props.longName == null - ? longName - : props.shortName == null && shortName} - - - - - ) -} - -export default NextHead diff --git a/components/Head/CommonHead.tsx b/components/NextHead.tsx similarity index 77% rename from components/Head/CommonHead.tsx rename to components/NextHead.tsx index ef02ddf..64906d8 100644 --- a/components/Head/CommonHead.tsx +++ b/components/NextHead.tsx @@ -1,12 +1,20 @@ -// eslint-disable-next-line @next/next/no-document-import-in-page -import { Head } from 'next/document' +import Head from 'next/head' +import useTranslation from 'next-translate/useTranslation' import { projectConfig } from 'utils/config' -export const CommonHead = (): JSX.Element => { +interface HeadProps { + title?: string +} + +const NextHead: React.FC = (props) => { + const { title = projectConfig.shortName } = props + + const { lang } = useTranslation() + return ( - {/* Link Tags */} + {title} { {/* Default meta tags */} + - + @@ -51,7 +60,10 @@ export const CommonHead = (): JSX.Element => { - + {/* Twitter card Metadata */} @@ -62,3 +74,5 @@ export const CommonHead = (): JSX.Element => { ) } + +export default NextHead diff --git a/pages/_document.tsx b/pages/_document.tsx index 9ca66ec..3367431 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -1,12 +1,10 @@ -import Document, { Html, Main, NextScript } from 'next/document' - -import { CommonHead } from 'components/Head/CommonHead' +import Document, { Head, Html, Main, NextScript } from 'next/document' class MyDocument extends Document { render(): JSX.Element { return ( - +