aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/helpers/schema-org.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-09-26 15:54:28 +0200
committerArmand Philippot <git@armandphilippot.com>2023-10-24 12:23:48 +0200
commit70efcfeaa0603415dd992cb662d8efb960e6e49a (patch)
tree5d37e98fae9aa7e5c3d8ef30a10db9fed9b63e36 /src/utils/helpers/schema-org.ts
parent31695306bfed44409f03006ea717fd2cceff8f87 (diff)
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.
Diffstat (limited to 'src/utils/helpers/schema-org.ts')
-rw-r--r--src/utils/helpers/schema-org.ts13
1 files changed, 7 insertions, 6 deletions
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 = <T extends SinglePageSchemaKind>({
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 = <T extends SinglePageSchemaKind>({
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}`,