From 18186f2014c09b961da74e5b84dc78d70d8db50e Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 3 Jul 2022 15:02:09 +0200 Subject: [PATCH] Added wiki pages to revalidate --- src/pages/api/revalidate.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/pages/api/revalidate.ts b/src/pages/api/revalidate.ts index e8791ec..efcd978 100644 --- a/src/pages/api/revalidate.ts +++ b/src/pages/api/revalidate.ts @@ -8,7 +8,8 @@ type RequestProps = | HookChronology | HookContent | HookContentGroup - | HookCustom; + | HookCustom + | HookWiki; type HookRangedContent = { event: "entry.update" | "entry.delete" | "entry.create"; @@ -76,6 +77,14 @@ type HookChronology = { model: "chronology-era" | "chronology-item"; }; +type HookWiki = { + event: "entry.update" | "entry.delete" | "entry.create"; + model: "wiki-page"; + entry: { + slug: string; + }; +}; + type ResponseMailProps = { message: string; revalidated: boolean; @@ -191,6 +200,17 @@ const Revalidate = async ( break; } + case "wiki-page": { + paths.push(`/wiki`); + paths.push(`/wiki/${body.entry.slug}`); + serverRuntimeConfig.locales?.map((locale: string) => { + paths.push(`/${locale}/wiki`); + paths.push(`/${locale}/wiki/${body.entry.slug}`); + }); + + break; + } + case "custom": { paths.push(`${body.url}`); break;