mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 14:06:59 +00:00
Update revalidate paths again
This commit is contained in:
parent
50e76973b7
commit
4b33503631
@ -1,4 +1,5 @@
|
|||||||
import { isValidSignature, SIGNATURE_HEADER_NAME } from '@sanity/webhook';
|
import { isValidSignature, SIGNATURE_HEADER_NAME } from '@sanity/webhook';
|
||||||
|
import { i18n } from 'i18n-config';
|
||||||
import { revalidatePath } from 'next/cache';
|
import { revalidatePath } from 'next/cache';
|
||||||
import { headers } from 'next/headers';
|
import { headers } from 'next/headers';
|
||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
@ -26,9 +27,21 @@ export async function POST(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const slug: string = requestData.slug;
|
const slug: string = requestData.slug;
|
||||||
|
const type: string = requestData.type;
|
||||||
|
const locale: string = requestData.locale;
|
||||||
|
|
||||||
|
if (type === 'home') {
|
||||||
revalidatePath(`${slug}`)
|
revalidatePath(`${slug}`)
|
||||||
|
|
||||||
console.log(`Revalidated path: ${slug}`);
|
console.log(`Revalidated path: ${slug}`);
|
||||||
|
} else {
|
||||||
|
if (i18n.defaultLocale === locale) {
|
||||||
|
revalidatePath(`${slug}`)
|
||||||
|
console.log(`Revalidated path: ${slug}`);
|
||||||
|
} else {
|
||||||
|
revalidatePath(`${locale}${slug}`)
|
||||||
|
console.log(`Revalidated path: ${locale}${slug}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json({ revalidated: true, now: Date.now() });
|
return NextResponse.json({ revalidated: true, now: Date.now() });
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user