aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/mentions-legales.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-05-23 19:02:20 +0200
committerArmand Philippot <git@armandphilippot.com>2022-05-23 19:02:20 +0200
commit5ebd7c14f7303a0feb8ec1d902ecd0e287d929c3 (patch)
tree4e0e0352ac7598fa4e186230e93bcc4c1ac6b810 /src/pages/mentions-legales.tsx
parent34e216546151eaf8a0a3cbb0bc8b65dae4c63bf2 (diff)
refactor(schema): use helpers function to avoid repeat between pages
Diffstat (limited to 'src/pages/mentions-legales.tsx')
-rw-r--r--src/pages/mentions-legales.tsx62
1 files changed, 21 insertions, 41 deletions
diff --git a/src/pages/mentions-legales.tsx b/src/pages/mentions-legales.tsx
index c8d1772..a58a850 100644
--- a/src/pages/mentions-legales.tsx
+++ b/src/pages/mentions-legales.tsx
@@ -7,6 +7,11 @@ import PageLayout, {
import LegalNoticeContent, { meta } from '@content/pages/legal-notice.mdx';
import { type NextPageWithLayout } from '@ts/types/app';
import { loadTranslation } from '@utils/helpers/i18n';
+import {
+ getSchemaJson,
+ getSinglePageSchema,
+ getWebPageSchema,
+} from '@utils/helpers/schema-org';
import useBreadcrumb from '@utils/hooks/use-breadcrumb';
import useSettings from '@utils/hooks/use-settings';
import { NestedMDXComponents } from 'mdx/types';
@@ -14,7 +19,6 @@ import { GetStaticProps } from 'next';
import Head from 'next/head';
import { useRouter } from 'next/router';
import Script from 'next/script';
-import { Article, Graph, WebPage } from 'schema-dts';
/**
* Legal Notice page.
@@ -44,47 +48,23 @@ const LegalNoticePage: NextPageWithLayout = () => {
const { website } = useSettings();
const { asPath } = useRouter();
- const pageUrl = `${website.url}${asPath}`;
- const pagePublicationDate = new Date(dates.publication);
- const pageUpdateDate = dates.update ? new Date(dates.update) : undefined;
-
- const webpageSchema: WebPage = {
- '@id': `${pageUrl}`,
- '@type': 'WebPage',
- breadcrumb: { '@id': `${website.url}/#breadcrumb` },
- name: seo.title,
+ const webpageSchema = getWebPageSchema({
description: seo.description,
- inLanguage: website.locales.default,
- license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr',
- reviewedBy: { '@id': `${website.url}/#branding` },
- url: `${pageUrl}`,
- isPartOf: {
- '@id': `${website.url}`,
- },
- };
-
- const articleSchema: Article = {
- '@id': `${website.url}/#legal-notice`,
- '@type': 'Article',
- name: title,
+ locale: website.locales.default,
+ slug: asPath,
+ title: seo.title,
+ updateDate: dates.update,
+ });
+ const articleSchema = getSinglePageSchema({
+ dates,
description: intro,
- author: { '@id': `${website.url}/#branding` },
- copyrightYear: pagePublicationDate.getFullYear(),
- creator: { '@id': `${website.url}/#branding` },
- dateCreated: pagePublicationDate.toISOString(),
- dateModified: pageUpdateDate && pageUpdateDate.toISOString(),
- datePublished: pagePublicationDate.toISOString(),
- editor: { '@id': `${website.url}/#branding` },
- headline: title,
- inLanguage: website.locales.default,
- license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr',
- mainEntityOfPage: { '@id': `${pageUrl}` },
- };
-
- const schemaJsonLd: Graph = {
- '@context': 'https://schema.org',
- '@graph': [webpageSchema, articleSchema],
- };
+ id: 'legal-notice',
+ kind: 'page',
+ locale: website.locales.default,
+ slug: asPath,
+ title,
+ });
+ const schemaJsonLd = getSchemaJson([webpageSchema, articleSchema]);
return (
<PageLayout
@@ -98,7 +78,7 @@ const LegalNoticePage: NextPageWithLayout = () => {
<Head>
<title>{`${seo.title} - ${website.name}`}</title>
<meta name="description" content={seo.description} />
- <meta property="og:url" content={`${pageUrl}`} />
+ <meta property="og:url" content={`${website.url}${asPath}`} />
<meta property="og:type" content="article" />
<meta property="og:title" content={`${seo.title} - ${website.name}`} />
<meta property="og:description" content={intro} />