From 7063b199b4748a9c354ed37e64cdc84c512f2c0c Mon Sep 17 00:00:00 2001 From: Armand Philippot 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/strings.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/utils/helpers/strings.ts') diff --git a/src/utils/helpers/strings.ts b/src/utils/helpers/strings.ts index 1f40b8f..d1de8ce 100644 --- a/src/utils/helpers/strings.ts +++ b/src/utils/helpers/strings.ts @@ -60,3 +60,6 @@ export const trimTrailingChars = (str: string, char: string): string => { return str.replace(regExp, ''); }; + +export const trimHTMLTags = (str: string) => + str.replace(/(?:<(?:[^>]+)>)/gi, '').replaceAll('\n\n\n\n', '\n\n'); -- cgit v1.2.3