aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/cv.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/cv.tsx
parent34e216546151eaf8a0a3cbb0bc8b65dae4c63bf2 (diff)
refactor(schema): use helpers function to avoid repeat between pages
Diffstat (limited to 'src/pages/cv.tsx')
-rw-r--r--src/pages/cv.tsx61
1 files changed, 22 insertions, 39 deletions
diff --git a/src/pages/cv.tsx b/src/pages/cv.tsx
index 3f035d8..4686505 100644
--- a/src/pages/cv.tsx
+++ b/src/pages/cv.tsx
@@ -11,6 +11,11 @@ import CVContent, { data, meta } from '@content/pages/cv.mdx';
import styles from '@styles/pages/cv.module.scss';
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';
@@ -20,7 +25,6 @@ import { useRouter } from 'next/router';
import Script from 'next/script';
import React, { ReactNode } from 'react';
import { useIntl } from 'react-intl';
-import { AboutPage, Graph, WebPage } from 'schema-dts';
/**
* CV page.
@@ -106,45 +110,24 @@ const CVPage: NextPageWithLayout = () => {
];
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,
- reviewedBy: { '@id': `${website.url}/#branding` },
- url: `${pageUrl}`,
- isPartOf: {
- '@id': `${website.url}`,
- },
- };
-
- const cvSchema: AboutPage = {
- '@id': `${website.url}/#cv`,
- '@type': 'AboutPage',
- name: seo.title,
+ locale: website.locales.default,
+ slug: asPath,
+ title: seo.title,
+ updateDate: dates.update,
+ });
+ const cvSchema = getSinglePageSchema({
+ cover: image.src,
+ dates,
description: intro,
- author: { '@id': `${website.url}/#branding` },
- creator: { '@id': `${website.url}/#branding` },
- dateCreated: pagePublicationDate.toISOString(),
- dateModified: pageUpdateDate && pageUpdateDate.toISOString(),
- datePublished: pagePublicationDate.toISOString(),
- editor: { '@id': `${website.url}/#branding` },
- image: image.src,
- inLanguage: website.locales.default,
- license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr',
- thumbnailUrl: image.src,
- mainEntityOfPage: { '@id': `${pageUrl}` },
- };
-
- const schemaJsonLd: Graph = {
- '@context': 'https://schema.org',
- '@graph': [webpageSchema, cvSchema],
- };
+ id: 'cv',
+ kind: 'about',
+ locale: website.locales.default,
+ slug: asPath,
+ title: title,
+ });
+ const schemaJsonLd = getSchemaJson([webpageSchema, cvSchema]);
const components: NestedMDXComponents = {
a: (props) => <Link external={true} {...props} />,
@@ -171,7 +154,7 @@ const CVPage: 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={title} />
<meta property="og:description" content={intro} />