diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-19 13:56:34 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-19 14:22:28 +0100 |
| commit | a26b775b7bbf1abd3e99c8bf9ce4c7522d3a0adc (patch) | |
| tree | 7f041845fa64d00f20f949d1cba14fec3eca3435 /src/components/Layouts | |
| parent | 813084fc23113ae2f594bf6ef1cf53bd003c9479 (diff) | |
chore: add structured data using schema.org and JSON-LD
I also added the featured image on single article.
Diffstat (limited to 'src/components/Layouts')
| -rw-r--r-- | src/components/Layouts/Layout.tsx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/components/Layouts/Layout.tsx b/src/components/Layouts/Layout.tsx index f5116f8..2e7d255 100644 --- a/src/components/Layouts/Layout.tsx +++ b/src/components/Layouts/Layout.tsx @@ -7,6 +7,7 @@ import { t } from '@lingui/macro'; import Head from 'next/head'; import { config } from '@config/website'; import { useRouter } from 'next/router'; +import { WebSite, WithContext } from 'schema-dts'; const Layout = ({ children, @@ -22,6 +23,25 @@ const Layout = ({ ref.current?.focus(); }, [asPath]); + const schemaJsonLd: WithContext<WebSite> = { + '@context': 'https://schema.org', + '@id': `${config.url}`, + '@type': 'WebSite', + name: config.name, + description: config.baseline, + url: config.url, + author: { '@id': `${config.url}/#branding` }, + copyrightYear: Number(config.copyright.startYear), + creator: { '@id': `${config.url}/#branding` }, + editor: { '@id': `${config.url}/#branding` }, + inLanguage: config.defaultLocale, + potentialAction: { + '@type': 'SearchAction', + target: `${config.url}/recherche?s={query}`, + query: 'required', + }, + }; + return ( <> <Head> @@ -43,6 +63,10 @@ const Layout = ({ type="application/feed+json" title={`${config.name}'s RSS feed`} /> + <script + type="application/ld+json" + dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} + ></script> </Head> <span ref={ref} tabIndex={-1} /> <a href="#main" className="screen-reader-text">{t`Skip to content`}</a> |
