// src/payload/collections/BlogPosts/hooks/revalidatePost.ts import type { AfterChangeHook } from 'payload/dist/collections/config/types'; import { revalidate } from '@/payload/utilities/revalidate'; // Revalidate the post in the background, so the user doesn't have to wait // Notice that the hook itself is not async and we are not awaiting `revalidate` export const revalidatePost: AfterChangeHook = ({ doc, req: { payload } }) => { revalidate({ payload, slug: `blog/${doc.id}` }); // Revalidate the blog overview page revalidate({ payload, slug: '[locale]/(default)/blog' }); return doc; };