Update revalidate paths again

This commit is contained in:
Henrik Larsson 2023-07-07 15:50:12 +02:00
parent ae90b68b04
commit 50e76973b7

View File

@ -1,5 +1,4 @@
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';
@ -26,19 +25,9 @@ export async function POST(request: NextRequest) {
return;
}
const slug = requestData.slug;
const type = requestData.type;
const locale = requestData.locale;
const slug: string = requestData.slug;
if (type === 'home') {
revalidatePath(`${slug}`)
} else {
if (i18n.defaultLocale === locale) {
revalidatePath(`${slug}`)
} else {
revalidatePath(`/${locale}${slug}`)
}
}
revalidatePath(`${slug}`)
console.log(`Revalidated path: ${slug}`);
return NextResponse.json({ revalidated: true, now: Date.now() });