From 7063b199b4748a9c354ed37e64cdc84c512f2c0c Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Thu, 14 Dec 2023 15:30:34 +0100
Subject: refactor(pages): rewrite helpers to output schema in json-ld format

* make sure url are absolutes
* nest breadcrumb schema in webpage schema
* trim HTML tags from content/description
* use a regular script instead of next/script (with the latter the
schema is not updated on route change)
* place the script in document head
* add keywords, wordCount and readingTime keys in BlogPosting schema
* fix breadcrumbs in search page (without query)
* add tests (a `MatchInlineSnapshot` will be better but Prettier 3 is
not supported yet)
---
 src/utils/helpers/pages.tsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'src/utils/helpers/pages.tsx')

diff --git a/src/utils/helpers/pages.tsx b/src/utils/helpers/pages.tsx
index 24f5503..1f70e8e 100644
--- a/src/utils/helpers/pages.tsx
+++ b/src/utils/helpers/pages.tsx
@@ -1,7 +1,7 @@
 import NextImage from 'next/image';
 import type { LinksWidgetItemData, PostData } from '../../components';
 import type { ArticlePreview, PageLink } from '../../types';
-import { ROUTES } from '../constants';
+import { COMMENTS_SECTION_ID, ROUTES } from '../constants';
 
 export const getUniquePageLinks = (pageLinks: PageLink[]): PageLink[] => {
   const pageLinksIds = pageLinks.map((pageLink) => pageLink.id);
@@ -64,7 +64,7 @@ export const getPostsWithUrl = (posts: ArticlePreview[]): PostData[] =>
         comments: {
           count: meta.commentsCount ?? 0,
           postHeading: title,
-          url: `${ROUTES.ARTICLE}/${slug}#comments`,
+          url: `${ROUTES.ARTICLE}/${slug}#${COMMENTS_SECTION_ID}`,
         },
       },
       url: `${ROUTES.ARTICLE}/${slug}`,
-- 
cgit v1.2.3

