fix(SW-976): handle unlocalized entries revalidation
This commit is contained in:
@@ -29,6 +29,7 @@ const validateJsonBody = z.object({
|
|||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
locale: z.nativeEnum(Lang),
|
locale: z.nativeEnum(Lang),
|
||||||
|
publish_details: z.object({ locale: z.nativeEnum(Lang) }).optional(),
|
||||||
uid: z.string(),
|
uid: z.string(),
|
||||||
url: z.string().optional(),
|
url: z.string().optional(),
|
||||||
page_settings: z
|
page_settings: z
|
||||||
@@ -67,15 +68,19 @@ export async function POST(request: NextRequest) {
|
|||||||
data: { content_type, entry },
|
data: { content_type, entry },
|
||||||
},
|
},
|
||||||
} = validatedData
|
} = validatedData
|
||||||
const refsTag = generateRefsResponseTag(entry.locale, entry.uid)
|
|
||||||
const refTag = generateRefTag(entry.locale, content_type.uid, entry.uid)
|
// The publish_details.locale is the locale that the entry is published in, regardless if it is "localized" or not
|
||||||
const tag = generateTag(entry.locale, entry.uid)
|
const entryLocale = entry.publish_details?.locale ?? entry.locale
|
||||||
|
|
||||||
|
const refsTag = generateRefsResponseTag(entryLocale, entry.uid)
|
||||||
|
const refTag = generateRefTag(entryLocale, content_type.uid, entry.uid)
|
||||||
|
const tag = generateTag(entryLocale, entry.uid)
|
||||||
const languageSwitcherTag = generateTag(
|
const languageSwitcherTag = generateTag(
|
||||||
entry.locale,
|
entryLocale,
|
||||||
entry.uid,
|
entry.uid,
|
||||||
languageSwitcherAffix
|
languageSwitcherAffix
|
||||||
)
|
)
|
||||||
const metadataTag = generateTag(entry.locale, entry.uid, metadataAffix)
|
const metadataTag = generateTag(entryLocale, entry.uid, metadataAffix)
|
||||||
|
|
||||||
console.info(`Revalidating refsTag: ${refsTag}`)
|
console.info(`Revalidating refsTag: ${refsTag}`)
|
||||||
revalidateTag(refsTag)
|
revalidateTag(refsTag)
|
||||||
@@ -94,12 +99,12 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
if (entry.breadcrumbs) {
|
if (entry.breadcrumbs) {
|
||||||
const breadcrumbsRefsTag = generateRefsResponseTag(
|
const breadcrumbsRefsTag = generateRefsResponseTag(
|
||||||
entry.locale,
|
entryLocale,
|
||||||
entry.uid,
|
entry.uid,
|
||||||
breadcrumbsAffix
|
breadcrumbsAffix
|
||||||
)
|
)
|
||||||
const breadcrumbsTag = generateTag(
|
const breadcrumbsTag = generateTag(
|
||||||
entry.locale,
|
entryLocale,
|
||||||
entry.uid,
|
entry.uid,
|
||||||
breadcrumbsAffix
|
breadcrumbsAffix
|
||||||
)
|
)
|
||||||
@@ -113,7 +118,7 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
if (entry.page_settings?.hide_booking_widget) {
|
if (entry.page_settings?.hide_booking_widget) {
|
||||||
const bookingwidgetTag = generateTag(
|
const bookingwidgetTag = generateTag(
|
||||||
entry.locale,
|
entryLocale,
|
||||||
entry.uid,
|
entry.uid,
|
||||||
bookingwidgetAffix
|
bookingwidgetAffix
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user