From 70efcfeaa0603415dd992cb662d8efb960e6e49a Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 26 Sep 2023 15:54:28 +0200 Subject: refactor(routes): replace hardcoded routes with constants It makes it easier to change a route if needed and it avoid typo mistakes. I also refactored a bit the concerned files to be complient with the new ESlint config. However, I should rewrite the pages to reduce the number of statements. --- src/utils/helpers/schema-org.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/utils/helpers/schema-org.ts') diff --git a/src/utils/helpers/schema-org.ts b/src/utils/helpers/schema-org.ts index 82f99c2..12bad28 100644 --- a/src/utils/helpers/schema-org.ts +++ b/src/utils/helpers/schema-org.ts @@ -1,4 +1,4 @@ -import { +import type { AboutPage, Article, Blog, @@ -7,8 +7,9 @@ import { Graph, WebPage, } from 'schema-dts'; -import { type Dates } from '../../types'; -import { settings } from '../../utils/config'; +import type { Dates } from '../../types'; +import { settings } from '../config'; +import { ROUTES } from '../constants'; export type GetBlogSchemaProps = { /** @@ -146,7 +147,7 @@ export const getSinglePageSchema = ({ copyrightYear: publicationDate.getFullYear(), creator: { '@id': `${settings.url}/#branding` }, dateCreated: publicationDate.toISOString(), - dateModified: updateDate && updateDate.toISOString(), + dateModified: updateDate?.toISOString(), datePublished: publicationDate.toISOString(), editor: { '@id': `${settings.url}/#branding` }, headline: title, @@ -157,7 +158,7 @@ export const getSinglePageSchema = ({ isPartOf: kind === 'post' ? { - '@id': `${settings.url}/blog`, + '@id': `${settings.url}${ROUTES.BLOG}`, } : undefined, mainEntityOfPage: { '@id': `${settings.url}${slug}` }, @@ -206,7 +207,7 @@ export const getWebPageSchema = ({ breadcrumb: { '@id': `${settings.url}/#breadcrumb` }, lastReviewed: updateDate, name: title, - description: description, + description, inLanguage: locale, reviewedBy: { '@id': `${settings.url}/#branding` }, url: `${settings.url}${slug}`, -- cgit v1.2.3