From 9ac3b266a87eb08b8ba49a4cb34a8639ab931c3f Mon Sep 17 00:00:00 2001 From: Padmaja <52911293+padms@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:24:17 +0530 Subject: [PATCH] :sparkles: Revalidate newsroom pages #2657 --- web/pages/api/revalidate.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/pages/api/revalidate.js b/web/pages/api/revalidate.js index 346ed104f..8980cec38 100644 --- a/web/pages/api/revalidate.js +++ b/web/pages/api/revalidate.js @@ -32,6 +32,13 @@ export default async function handler(req, res) { }) } + const revalidateNewsroomPages = async () => { + console.log(new Date(), 'Revalidating: /news') + res.revalidate(`/news`) + console.log(new Date(), 'Revalidating: /no/nyheter') + res.revalidate('/no/nyheter') + } + if (['page', 'landingPage', 'event'].includes(data._type)) { const routes = await sanityClient.fetch( groq`*[_type match "route_*" && content._ref == $id]{"slug": slug.current}`, @@ -53,6 +60,8 @@ export default async function handler(req, res) { console.log(new Date(), 'Revalidating: ', data?.slug) if (data.slug) await res.revalidate(data.slug) await revalidateHomePages() + // revalidate newsroom pages + if (data._type === 'news') await revalidateNewsroomPages() return res.json({ revalidated: true, slug: data.slug }) } } catch (err) {