diff --git a/src/collections/ContactPerson.ts b/src/collections/ContactPerson.ts index 261881f..31bf311 100644 --- a/src/collections/ContactPerson.ts +++ b/src/collections/ContactPerson.ts @@ -1,5 +1,6 @@ -import { CollectionConfig } from 'payload' + import { CollectionConfig } from 'payload' import { hide, isAdminOrEmployee } from '@/collections/access/admin' +import { revalidateTagHook } from '@/utils/revalidate' export const ContactPerson: CollectionConfig = { slug: 'contactPerson', @@ -54,4 +55,10 @@ export const ContactPerson: CollectionConfig = { update: isAdminOrEmployee(), delete: isAdminOrEmployee(), }, + hooks: { + // Pages and events embed contacts via relationships, so their caches + // hold a copy of the contact and must be invalidated on change. + afterChange: [revalidateTagHook('pages'), revalidateTagHook('events')], + afterDelete: [revalidateTagHook('pages'), revalidateTagHook('events')], + }, } \ No newline at end of file diff --git a/src/fetch/pages.ts b/src/fetch/pages.ts index e1d2118..be4ad44 100644 --- a/src/fetch/pages.ts +++ b/src/fetch/pages.ts @@ -28,5 +28,6 @@ export async function fetchPageBySlug( return unstable_cache(fetchPage, ['pages', slug], { tags: ['pages', `pages-${slug}`], + revalidate: 3600, })() }