From 38ae1fbaa7c6dcbfecf2fb7bb8f2443e0dbc14a5 Mon Sep 17 00:00:00 2001 From: GustaveWPM Date: Fri, 10 May 2024 00:30:03 +0200 Subject: [PATCH 1/2] feat: some SEO artefacts --- interop/config/contentlayer/adapters.ts | 9 +- .../contentlayerConfigTweakers.ts | 16 ++- .../config/contentlayer/nested-types/SEO.ts | 98 +++++++++++++++++++ .../(pages)/(withfooter)/[...path]/page.tsx | 6 +- src/lib/blog/staticGeneration.ts | 14 ++- src/lib/landingPages/staticGeneration.ts | 10 +- ...sStaticParams.disabled_drafts_prod.test.ts | 6 +- ...esStaticParams.enabled_drafts_prod.test.ts | 6 +- ...etPagesStaticParams.index_notation.test.ts | 6 +- ...uild.getPagesStaticParams.skip_ssg.test.ts | 6 +- ...PagesStaticParams.unknown_language.test.ts | 6 +- ...StaticParams.ts => getPageStaticParams.ts} | 4 +- src/lib/pages/staticGeneration.ts | 20 ++-- 13 files changed, 171 insertions(+), 36 deletions(-) create mode 100644 interop/config/contentlayer/nested-types/SEO.ts rename src/lib/pages/static/{getPagesStaticParams.ts => getPageStaticParams.ts} (91%) diff --git a/interop/config/contentlayer/adapters.ts b/interop/config/contentlayer/adapters.ts index f8d5131de..d0b46fc43 100644 --- a/interop/config/contentlayer/adapters.ts +++ b/interop/config/contentlayer/adapters.ts @@ -1,4 +1,4 @@ -import type { DocumentTypeDef } from 'contentlayer/source-files'; +import type { NestedUnnamedTypeDef, DocumentTypeDef, NestedTypeDef, NestedType } from 'contentlayer/source-files'; // * ... Adapter (narrowing) // * ... Also made because importing `defineDocumentType` from `contentlayer/source-files` is not possible (loaders hell) @@ -7,3 +7,10 @@ export const defineDocumentType = (def: () => DocumentTypeDef) => type: 'document', def }) as const; + +// * ... Adapter (narrowing) +// * ... Also made because importing `defineNestedType` from `contentlayer/source-files` is not possible (loaders hell) +export const defineNestedType = (def: () => NestedTypeDef | NestedUnnamedTypeDef): NestedType => ({ + type: 'nested', + def +}); diff --git a/interop/config/contentlayer/contentlayerConfigTweakers.ts b/interop/config/contentlayer/contentlayerConfigTweakers.ts index 15add9e18..aa6f0f5ba 100644 --- a/interop/config/contentlayer/contentlayerConfigTweakers.ts +++ b/interop/config/contentlayer/contentlayerConfigTweakers.ts @@ -25,6 +25,7 @@ import { buildPageUrl } from '../../lib/builders'; import { blogTagOptions } from './blog/blogTags'; +import SEO from './nested-types/SEO'; export const PAGES_FOLDER = 'pages'; export const BLOG_POSTS_FOLDER = 'blog'; @@ -107,6 +108,8 @@ const _ALL_BLOG_FIELDS = { required: true }, + seo: { required: false, type: 'nested', of: SEO }, + date: { required: true, type: 'date' @@ -151,6 +154,8 @@ const _ALL_LANDING_PAGES_FIELDS = { required: true }, + seo: { required: false, type: 'nested', of: SEO }, + url: { type: 'string', required: true @@ -189,6 +194,8 @@ const _ALL_PAGES_FIELDS = { required: true }, + seo: { required: false, type: 'nested', of: SEO }, + url: { type: 'string', required: true @@ -217,7 +224,8 @@ export const BLOG_DOCUMENTS_FIELDS = { draft: _ALL_BLOG_FIELDS.draft, title: _ALL_BLOG_FIELDS.title, tags: _ALL_BLOG_FIELDS.tags, - date: _ALL_BLOG_FIELDS.date + date: _ALL_BLOG_FIELDS.date, + seo: _ALL_BLOG_FIELDS.seo } as const satisfies DocumentsFields<_AllBlogFields, _BlogDocumentsComputedFieldsKeys>; export const BLOG_POST_SCHEMA_CONFIG: ContentlayerDocumentsConfigType = { @@ -244,7 +252,8 @@ export const LANDING_PAGES_DOCUMENTS_FIELDS = { doNotExcludeFromLocalSearch: _ALL_LANDING_PAGES_FIELDS.doNotExcludeFromLocalSearch, metadescription: _ALL_LANDING_PAGES_FIELDS.metadescription, draft: _ALL_LANDING_PAGES_FIELDS.draft, - title: _ALL_LANDING_PAGES_FIELDS.title + title: _ALL_LANDING_PAGES_FIELDS.title, + seo: _ALL_LANDING_PAGES_FIELDS.seo } as const satisfies DocumentsFields<_AllLandingPagesFields, _LandingPagesDocumentsComputedFieldsKeys>; /* v8 ignore start */ @@ -263,7 +272,8 @@ export const PAGES_DOCUMENTS_COMPUTED_FIELDS = { export const PAGES_DOCUMENTS_FIELDS = { metadescription: _ALL_PAGES_FIELDS.metadescription, draft: _ALL_PAGES_FIELDS.draft, - title: _ALL_PAGES_FIELDS.title + title: _ALL_PAGES_FIELDS.title, + seo: _ALL_PAGES_FIELDS.seo } as const satisfies DocumentsFields<_AllPagesFields, _PagesDocumentsComputedFieldsKeys>; type BlogPostSchemaKey = 'BlogPostSchema'; diff --git a/interop/config/contentlayer/nested-types/SEO.ts b/interop/config/contentlayer/nested-types/SEO.ts new file mode 100644 index 000000000..dbecbdc27 --- /dev/null +++ b/interop/config/contentlayer/nested-types/SEO.ts @@ -0,0 +1,98 @@ +import { defineNestedType } from '../adapters'; + +// * ... Inspired from https://github.com/contentlayerdev/contentlayer/blob/main/examples/archive/playground-azimuth/src/contentlayer/nested/SEO.ts + +const Robots = defineNestedType(() => ({ + fields: { + nositelinkssearchbox: { required: false, type: 'boolean', default: false }, + indexifembedded: { required: false, type: 'boolean', default: true }, + noimageindex: { required: false, type: 'boolean', default: false }, + notranslate: { required: false, type: 'boolean', default: false }, + noarchive: { required: false, type: 'boolean', default: false }, + nosnippet: { required: false, type: 'boolean', default: false }, + nocache: { required: false, type: 'boolean', default: false }, + follow: { required: false, type: 'boolean', default: true }, + index: { required: false, type: 'boolean', default: true } + } +})); + +const AlternateLinkDescriptor = defineNestedType(() => ({ + fields: { + title: { required: false, type: 'string' }, + url: { required: true, type: 'string' } + } +})); + +const Alternates = defineNestedType(() => ({ + fields: { + canonical: { of: AlternateLinkDescriptor, required: false, type: 'nested' } + } +})); + +const OGImageDescriptor = defineNestedType(() => ({ + fields: { + secureUrl: { required: false, type: 'string' }, + height: { required: false, type: 'number' }, + width: { required: false, type: 'number' }, + type: { required: false, type: 'string' }, + alt: { required: false, type: 'string' }, + url: { required: true, type: 'string' } + } +})); + +const OGAudioDescriptor = defineNestedType(() => ({ + fields: { + secureUrl: { required: false, type: 'string' }, + type: { required: false, type: 'string' }, + url: { required: true, type: 'string' } + } +})); + +const OGVideoDescriptor = defineNestedType(() => ({ + fields: { + secureUrl: { required: false, type: 'string' }, + height: { required: false, type: 'number' }, + width: { required: false, type: 'number' }, + type: { required: false, type: 'string' }, + url: { required: true, type: 'string' } + } +})); + +const OpenGraph = defineNestedType(() => ({ + fields: { + images: { of: OGImageDescriptor, required: false, type: 'list' }, + videos: { of: OGVideoDescriptor, required: false, type: 'list' }, + audio: { of: OGAudioDescriptor, required: false, type: 'list' }, + description: { required: false, type: 'string' }, + title: { required: false, type: 'string' } + } +})); + +const SEO = defineNestedType(() => ({ + fields: { + alternates: { + description: 'The canonical and alternate URLs for the document', + required: false, + type: 'nested', + of: Alternates + }, + + robots: { + description: 'The items that go into the tag', + required: false, + type: 'nested', + of: Robots + }, + + openGraph: { + description: 'The Open Graph data', + required: false, + type: 'nested', + of: OpenGraph + } + }, + + name: 'SEO' +})); + +export default SEO; diff --git a/src/app/[locale]/(pages)/(withfooter)/[...path]/page.tsx b/src/app/[locale]/(pages)/(withfooter)/[...path]/page.tsx index 8390d4ba9..47ca5c573 100644 --- a/src/app/[locale]/(pages)/(withfooter)/[...path]/page.tsx +++ b/src/app/[locale]/(pages)/(withfooter)/[...path]/page.tsx @@ -1,6 +1,6 @@ import type { PageProps } from '@/types/Page'; -import { getPagesStaticParams, getPagesMetadatas } from '@/lib/pages/staticGeneration'; +import { getPageStaticParams, getPageMetadatas } from '@/lib/pages/staticGeneration'; import isSkippedPath from '@/lib/pages/static/helpers/isSkippedPath'; import { getPageByLanguageAndPathUnstrict } from '@/lib/pages/api'; import { setStaticParamsLocale } from 'next-international/server'; @@ -12,12 +12,12 @@ import { notFound } from 'next/navigation'; import { cn } from '@/lib/tailwind'; export async function generateMetadata({ params }: PageProps) { - const metadatas = await getPagesMetadatas({ params }); + const metadatas = await getPageMetadatas({ params }); return metadatas; } export function generateStaticParams() { - const staticParams = getPagesStaticParams(); + const staticParams = getPageStaticParams(); return staticParams; } diff --git a/src/lib/blog/staticGeneration.ts b/src/lib/blog/staticGeneration.ts index a23db68a0..7e95a7f35 100644 --- a/src/lib/blog/staticGeneration.ts +++ b/src/lib/blog/staticGeneration.ts @@ -10,6 +10,7 @@ import type { BlogPostType } from '@/types/Blog'; import type { MaybeNull } from '@rtm/shared-types/CustomUtilityTypes'; +import type { Metadata } from 'next'; import buildPageTitle from '@rtm/shared-lib/portable/str/buildPageTitle'; import BlogTaxonomy from '##/config/taxonomies/blog'; @@ -51,7 +52,7 @@ export async function getBlogSubcategoryMetadatas({ params }: BlogSubcategoryPag return { description, title }; } -export async function getBlogPostMetadatas({ params }: BlogPostPageProps) { +export async function getBlogPostMetadatas({ params }: BlogPostPageProps): Promise { const [category, subcategory, slug, language] = [ params[BlogTaxonomy.CATEGORY], params[BlogTaxonomy.SUBCATEGORY], @@ -67,8 +68,15 @@ export async function getBlogPostMetadatas({ params }: BlogPostPageProps) { if (!isValidBlogCategoryAndSubcategoryPair(category, subcategory, language)) return {}; const title = buildPageTitle(globalT(`${i18ns.vocab}.brand-short`), currentPost.title); - const { metadescription: description } = post as BlogPostType; - return { description, title }; + const { metadescription: description, seo } = currentPost; + + // {ToDo} Generate languages alternates + // https://github.com/Tirraa/dashboard_rtm/issues/58#issuecomment-2103311665 + + if (seo === undefined) return { description, title }; + + const { alternates, openGraph, robots } = seo; + return { description, alternates, openGraph, robots, title }; } export { blogSubcategoryGuard, blogCategoryGuard, blogPostGuard }; diff --git a/src/lib/landingPages/staticGeneration.ts b/src/lib/landingPages/staticGeneration.ts index b424a4499..8c6052181 100644 --- a/src/lib/landingPages/staticGeneration.ts +++ b/src/lib/landingPages/staticGeneration.ts @@ -26,12 +26,18 @@ export async function getLandingPageMetadatas({ params }: LandingPageProps) { if (!lp) notFound(); const globalT = await getServerSideI18n(); - const { metadescription: description, title: lpTitle } = lp; + const { metadescription: description, title: lpTitle, seo } = lp; const { vocab } = i18ns; const title = buildPageTitle(globalT(`${vocab}.brand-short`), lpTitle); - return { description, title }; + // {ToDo} Generate languages alternates + // https://github.com/Tirraa/dashboard_rtm/issues/58#issuecomment-2103311665 + + if (seo === undefined) return { description, title }; + + const { alternates, openGraph, robots } = seo; + return { description, alternates, openGraph, robots, title }; } // Stryker restore all diff --git a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.disabled_drafts_prod.test.ts b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.disabled_drafts_prod.test.ts index f5421ec40..7325af264 100644 --- a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.disabled_drafts_prod.test.ts +++ b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.disabled_drafts_prod.test.ts @@ -6,7 +6,7 @@ import PageTaxonomy from '##/config/taxonomies/pages'; import I18nTaxonomy from '##/config/taxonomies/i18n'; import { describe, expect, it, vi } from 'vitest'; -import getPagesStaticParams from '../getPagesStaticParams'; +import getPageStaticParams from '../getPageStaticParams'; vi.mock('../../../../../interop/config/i18n', async (orgImport) => { // eslint-disable-next-line @typescript-eslint/consistent-type-imports @@ -250,9 +250,9 @@ vi.mock('@/config/pages', async (orgImport) => { }; }); -describe('getPagesStaticParams', () => { +describe('getPageStaticParams', () => { it('should return static params according to the allPages mock', () => { - const staticParams = getPagesStaticParams(); + const staticParams = getPageStaticParams(); expect(staticParams).toStrictEqual([ { [PageTaxonomy.PATH]: ['page-00'], [I18nTaxonomy.LANGUAGE]: 'fr' }, diff --git a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.enabled_drafts_prod.test.ts b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.enabled_drafts_prod.test.ts index 5237097fd..1732cad12 100644 --- a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.enabled_drafts_prod.test.ts +++ b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.enabled_drafts_prod.test.ts @@ -6,7 +6,7 @@ import PageTaxonomy from '##/config/taxonomies/pages'; import I18nTaxonomy from '##/config/taxonomies/i18n'; import { describe, expect, it, vi } from 'vitest'; -import getPagesStaticParams from '../getPagesStaticParams'; +import getPageStaticParams from '../getPageStaticParams'; vi.mock('../../../../../interop/config/i18n', async (orgImport) => { // eslint-disable-next-line @typescript-eslint/consistent-type-imports @@ -249,9 +249,9 @@ vi.mock('@/config/pages', async (orgImport) => { }; }); -describe('getPagesStaticParams', () => { +describe('getPageStaticParams', () => { it('should return static params according to the allPages mock', () => { - const staticParams = getPagesStaticParams(); + const staticParams = getPageStaticParams(); expect(staticParams).toStrictEqual([ { [PageTaxonomy.PATH]: ['page-00'], [I18nTaxonomy.LANGUAGE]: 'fr' }, diff --git a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.index_notation.test.ts b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.index_notation.test.ts index 339d2ddb1..e49dbf72a 100644 --- a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.index_notation.test.ts +++ b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.index_notation.test.ts @@ -6,7 +6,7 @@ import PageTaxonomy from '##/config/taxonomies/pages'; import I18nTaxonomy from '##/config/taxonomies/i18n'; import { describe, expect, it, vi } from 'vitest'; -import getPagesStaticParams from '../getPagesStaticParams'; +import getPageStaticParams from '../getPageStaticParams'; vi.mock('../../../../../interop/config/i18n', async (orgImport) => { // eslint-disable-next-line @typescript-eslint/consistent-type-imports @@ -369,9 +369,9 @@ vi.mock('@/config/pages', async (orgImport) => { }; }); -describe('getPagesStaticParams (index notation)', () => { +describe('getPageStaticParams (index notation)', () => { it('should return static params according to the allPages mock', () => { - const staticParams = getPagesStaticParams(); + const staticParams = getPageStaticParams(); expect(staticParams).toStrictEqual([ { [PageTaxonomy.PATH]: ['index'], [I18nTaxonomy.LANGUAGE]: 'fr' }, diff --git a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.skip_ssg.test.ts b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.skip_ssg.test.ts index 72efe82f9..35d17a0a0 100644 --- a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.skip_ssg.test.ts +++ b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.skip_ssg.test.ts @@ -7,7 +7,7 @@ import PageTaxonomy from '##/config/taxonomies/pages'; import I18nTaxonomy from '##/config/taxonomies/i18n'; import { describe, expect, it, vi } from 'vitest'; -import getPagesStaticParams from '../getPagesStaticParams'; +import getPageStaticParams from '../getPageStaticParams'; vi.mock('../../../../../interop/config/i18n', async (orgImport) => { // eslint-disable-next-line @typescript-eslint/consistent-type-imports @@ -89,9 +89,9 @@ vi.mock('@/config/pages', async (orgImport) => { }; }); -describe('getPagesStaticParams', () => { +describe('getPageStaticParams', () => { it('should return static params according to the allPages mock', () => { - const staticParams = getPagesStaticParams(); + const staticParams = getPageStaticParams(); expect(staticParams).toStrictEqual([{ [PageTaxonomy.PATH]: ['nesting-1', 'nesting-2', 'page-00'], [I18nTaxonomy.LANGUAGE]: 'en' }]); }); diff --git a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.unknown_language.test.ts b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.unknown_language.test.ts index 75d98d994..9ccaf2ff2 100644 --- a/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.unknown_language.test.ts +++ b/src/lib/pages/static/__tests__/postbuild.getPagesStaticParams.unknown_language.test.ts @@ -6,7 +6,7 @@ import PageTaxonomy from '##/config/taxonomies/pages'; import I18nTaxonomy from '##/config/taxonomies/i18n'; import { describe, expect, it, vi } from 'vitest'; -import getPagesStaticParams from '../getPagesStaticParams'; +import getPageStaticParams from '../getPageStaticParams'; vi.mock('../../../../../interop/config/i18n', async (orgImport) => { // eslint-disable-next-line @typescript-eslint/consistent-type-imports @@ -267,9 +267,9 @@ vi.mock('@/config/pages', async (orgImport) => { }; }); -describe('getPagesStaticParams', () => { +describe('getPageStaticParams', () => { it('should return static params according to the allPages mock, ignoring __UNKNOWN_LANGUAGE__', () => { - const staticParams = getPagesStaticParams(); + const staticParams = getPageStaticParams(); expect(staticParams).toStrictEqual([ { [PageTaxonomy.PATH]: ['page-00'], [I18nTaxonomy.LANGUAGE]: 'fr' }, diff --git a/src/lib/pages/static/getPagesStaticParams.ts b/src/lib/pages/static/getPageStaticParams.ts similarity index 91% rename from src/lib/pages/static/getPagesStaticParams.ts rename to src/lib/pages/static/getPageStaticParams.ts index 8c28c9dcf..1b8455fd3 100644 --- a/src/lib/pages/static/getPagesStaticParams.ts +++ b/src/lib/pages/static/getPageStaticParams.ts @@ -5,7 +5,7 @@ import I18nTaxonomy from '##/config/taxonomies/i18n'; import { getPageByLanguageAndPathUnstrict, getAllPages } from '../api'; import isSkippedPath from './helpers/isSkippedPath'; -function getPagesStaticParams() { +function getPageStaticParams() { const staticParams = []; const allPages = getAllPages(); @@ -22,4 +22,4 @@ function getPagesStaticParams() { return staticParams; } -export default getPagesStaticParams; +export default getPageStaticParams; diff --git a/src/lib/pages/staticGeneration.ts b/src/lib/pages/staticGeneration.ts index 80edf6839..2d307cbe4 100644 --- a/src/lib/pages/staticGeneration.ts +++ b/src/lib/pages/staticGeneration.ts @@ -10,16 +10,16 @@ import { getServerSideI18n } from '@/i18n/server'; import { notFound } from 'next/navigation'; import { i18ns } from '##/config/i18n'; -import doGetPagesStaticParams from './static/getPagesStaticParams'; +import doGetPageStaticParams from './static/getPageStaticParams'; import isSkippedPath from './static/helpers/isSkippedPath'; import { getPageByLanguageAndPathUnstrict } from './api'; -export function getPagesStaticParams() { - const pagesStaticParams = doGetPagesStaticParams(); - return pagesStaticParams; +export function getPageStaticParams() { + const pageStaticParams = doGetPageStaticParams(); + return pageStaticParams; } -export async function getPagesMetadatas({ params }: PageProps) { +export async function getPageMetadatas({ params }: PageProps) { const [path, language] = [params[PageTaxonomy.PATH].join('/'), params[I18nTaxonomy.LANGUAGE]]; if (isSkippedPath(path)) notFound(); @@ -27,12 +27,18 @@ export async function getPagesMetadatas({ params }: PageProps) { if (!page) notFound(); const globalT = await getServerSideI18n(); - const { metadescription: description, title: pageTitle } = page; + const { metadescription: description, title: pageTitle, seo } = page; const { vocab } = i18ns; const title = buildPageTitle(globalT(`${vocab}.brand-short`), pageTitle); - return { description, title }; + // {ToDo} Generate languages alternates + // https://github.com/Tirraa/dashboard_rtm/issues/58#issuecomment-2103311665 + + if (seo === undefined) return { description, title }; + + const { alternates, openGraph, robots } = seo; + return { description, alternates, openGraph, robots, title }; } // Stryker restore all From 77e973cefce3048973b81ebbd6e723ea4e6f7a01 Mon Sep 17 00:00:00 2001 From: GustaveWPM Date: Fri, 10 May 2024 13:45:05 +0200 Subject: [PATCH 2/2] chore: added pagefind crash logging + testing it in prod --- .ts-prune/artifacts/tsprune-false-positives.conf | 9 +++++---- src/app/api/error/route.ts | 10 ++++++++++ .../layouts/navbar/search/ProgressiveResults.tsx | 14 +++++++++++--- 3 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 src/app/api/error/route.ts diff --git a/.ts-prune/artifacts/tsprune-false-positives.conf b/.ts-prune/artifacts/tsprune-false-positives.conf index 16d7d6e30..2d00ea8d5 100644 --- a/.ts-prune/artifacts/tsprune-false-positives.conf +++ b/.ts-prune/artifacts/tsprune-false-positives.conf @@ -324,14 +324,15 @@ src/types/adapters/PageAdapter.ts:12 - TopLevelRoot (used in module) # DO NOT DELETE THIS BEFORE A DOUBLE-CHECK! # Try to ts-prune with and without the .next folder, and see if # those false positives are always evaluated as outdated. -# 📊 Entries: 41 +# 📊 Entries: 42 #================================================================= -#------------------------ -# **** II. 1) NEXT AUTH -#------------------------ +#------------------------------ +# **** II. 1) NEXT AUTH / API +#------------------------------ src/app/api/auth/[...nextauth]/route.ts:8 - POST src/app/api/auth/[...nextauth]/route.ts:8 - GET +src/app/api/error/route.ts:4 - POST #------------------- # **** II. 2) NEXT diff --git a/src/app/api/error/route.ts b/src/app/api/error/route.ts new file mode 100644 index 000000000..d2b02bf1b --- /dev/null +++ b/src/app/api/error/route.ts @@ -0,0 +1,10 @@ +/* v8 ignore start */ +// Stryker disable all + +export async function POST(request: Request) { + const error = await request.json(); + console.warn(error); +} + +// Stryker restore all +/* v8 ignore stop */ diff --git a/src/components/layouts/navbar/search/ProgressiveResults.tsx b/src/components/layouts/navbar/search/ProgressiveResults.tsx index e17addd06..db2a5479e 100644 --- a/src/components/layouts/navbar/search/ProgressiveResults.tsx +++ b/src/components/layouts/navbar/search/ProgressiveResults.tsx @@ -134,6 +134,8 @@ const ProgressiveResults: FunctionComponent = ({ const intervalMs: MsValue = 250; let isComputing = false; + // {ToDo} Remove this line + // eslint-disable-next-line let retryInterval: MaybeNull = setInterval(async () => { function disposeRetryInterval() { // eslint-disable-next-line no-magic-numbers @@ -148,12 +150,18 @@ const ProgressiveResults: FunctionComponent = ({ try { if (isComputing) return; isComputing = true; - await throttledComputeAndSetResults(); - disposeRetryInterval(); + throw new Error('lol'); // {ToDo} Remove this line and uncomment the next lines + // await throttledComputeAndSetResults(); + // disposeRetryInterval(); } catch { retries++; if (maxRetries >= retries) { - // {ToDo} This should be logged + fetch('/api/error', { + body: JSON.stringify({ message: 'pagefindIntegrationError' }), + headers: { 'Content-Type': 'application/json' }, + method: 'POST' + }); + toast({ description: globalT(`${i18ns.brokenPagefindIntegrationError}.message`), title: globalT(`${i18ns.brokenPagefindIntegrationError}.title`),