From ae90b68b04093ca71b4dd24d8b6aa7be851a7517 Mon Sep 17 00:00:00 2001 From: Henrik Larsson Date: Fri, 7 Jul 2023 15:43:26 +0200 Subject: [PATCH] Update revalidate paths again --- app/api/revalidate/sanity/route.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/api/revalidate/sanity/route.ts b/app/api/revalidate/sanity/route.ts index 63146640a..5a20096d9 100644 --- a/app/api/revalidate/sanity/route.ts +++ b/app/api/revalidate/sanity/route.ts @@ -1,4 +1,5 @@ import { isValidSignature, SIGNATURE_HEADER_NAME } from '@sanity/webhook'; +import { i18n } from 'i18n-config'; import { revalidatePath } from 'next/cache'; import { headers } from 'next/headers'; import { NextRequest, NextResponse } from 'next/server'; @@ -27,11 +28,16 @@ export async function POST(request: NextRequest) { const slug = requestData.slug; const type = requestData.type; + const locale = requestData.locale; if (type === 'home') { revalidatePath(`${slug}`) } else { - revalidatePath(`${slug}`) + if (i18n.defaultLocale === locale) { + revalidatePath(`${slug}`) + } else { + revalidatePath(`/${locale}${slug}`) + } } console.log(`Revalidated path: ${slug}`);