feat(SW-237): Cache revalidation support
This commit is contained in:
@@ -6,6 +6,7 @@ import { z } from "zod"
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { env } from "@/env/server"
|
||||
import { internalServerError } from "@/server/errors/next"
|
||||
import { affix as bookingwidgetAffix } from "@/server/routers/contentstack/bookingwidget/utils"
|
||||
import { affix as breadcrumbsAffix } from "@/server/routers/contentstack/breadcrumbs/utils"
|
||||
import { languageSwitcherAffix } from "@/server/routers/contentstack/languageSwitcher/utils"
|
||||
|
||||
@@ -29,6 +30,11 @@ const validateJsonBody = z.object({
|
||||
locale: z.nativeEnum(Lang),
|
||||
uid: z.string(),
|
||||
url: z.string().optional(),
|
||||
page_settings: z
|
||||
.object({
|
||||
hide_booking_widget: z.boolean(),
|
||||
})
|
||||
.optional(),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
@@ -105,6 +111,17 @@ export async function POST(request: NextRequest) {
|
||||
revalidateTag(breadcrumbsTag)
|
||||
}
|
||||
|
||||
if (entry.page_settings?.hide_booking_widget) {
|
||||
const bookingwidgetTag = generateTag(
|
||||
entry.locale,
|
||||
entry.uid,
|
||||
bookingwidgetAffix
|
||||
)
|
||||
|
||||
console.info(`Revalidating breadcrumbsTag: ${bookingwidgetTag}`)
|
||||
revalidateTag(bookingwidgetTag)
|
||||
}
|
||||
|
||||
return Response.json({ revalidated: true, now: Date.now() })
|
||||
} catch (error) {
|
||||
console.error("Failed to revalidate tag(s)")
|
||||
|
||||
Reference in New Issue
Block a user