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/pages/cv.tsx | |
| 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/pages/cv.tsx')
| -rw-r--r-- | src/pages/cv.tsx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/pages/cv.tsx b/src/pages/cv.tsx index 01eab4c..78e9a6e 100644 --- a/src/pages/cv.tsx +++ b/src/pages/cv.tsx @@ -11,8 +11,12 @@ import styles from '@styles/pages/Page.module.scss'; import { CVPreview, SocialMedia, ToC } from '@components/Widgets'; import { t } from '@lingui/macro'; import Sidebar from '@components/Sidebar/Sidebar'; +import { AboutPage, Graph, WebPage } from 'schema-dts'; +import { config } from '@config/website'; +import { useRouter } from 'next/router'; const CV: NextPageWithLayout = () => { + const router = useRouter(); const dates = { publication: meta.publishedOn, update: meta.updatedOn, @@ -22,13 +26,57 @@ const CV: NextPageWithLayout = () => { dates, }; + const webpageSchema: WebPage = { + '@id': `${config.url}${router.asPath}`, + '@type': 'WebPage', + breadcrumb: { '@id': `${config.url}/#breadcrumb` }, + name: seo.cv.title, + description: seo.cv.description, + reviewedBy: { '@id': `${config.url}/#branding` }, + url: `${config.url}${router.asPath}`, + isPartOf: { + '@id': `${config.url}`, + }, + }; + + const publicationDate = new Date(dates.publication); + const updateDate = new Date(dates.update); + + const cvSchema: AboutPage = { + '@id': `${config.url}/#cv`, + '@type': 'AboutPage', + name: `${config.name} CV`, + description: intro, + author: { '@id': `${config.url}/#branding` }, + creator: { '@id': `${config.url}/#branding` }, + dateCreated: publicationDate.toISOString(), + dateModified: updateDate.toISOString(), + datePublished: publicationDate.toISOString(), + editor: { '@id': `${config.url}/#branding` }, + image, + inLanguage: config.defaultLocale, + license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', + thumbnailUrl: image, + mainEntityOfPage: { '@id': `${config.url}${router.asPath}` }, + }; + + const schemaJsonLd: Graph = { + '@context': 'https://schema.org', + '@graph': [webpageSchema, cvSchema], + }; + return ( <> <Head> <title>{seo.cv.title}</title> <meta name="description" content={seo.cv.description} /> + <script + type="application/ld+json" + dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} + ></script> </Head> <article + id="cv" className={`${styles.article} ${styles['article--no-comments']}`} > <PostHeader intro={intro} meta={pageMeta} title={meta.title} /> |
