Home / Function/ revalidateEvent() — supabase Function Reference

revalidateEvent() — supabase Function Reference

Architecture documentation for the revalidateEvent() function in revalidateEvent.ts from the supabase codebase.

Entity Profile

Relationship Graph

Source Code

apps/cms/src/collections/Events/hooks/revalidateEvent.ts lines 7–38

export const revalidateEvent: CollectionAfterChangeHook<Event> = async ({
  doc,
  previousDoc,
  req: { payload, context },
}) => {
  if (!context.disableRevalidate) {
    if (doc._status === 'published') {
      const path = `/events/${doc.slug}`

      payload.logger.info(`Revalidating event at path: ${path}`)
      try {
        const { revalidatePath, revalidateTag } = await import('next/cache')
        revalidatePath(path)
        revalidateTag('events-sitemap')
      } catch {}
    }

    // If the event was previously published, we need to revalidate the old path
    if (previousDoc._status === 'published' && doc._status !== 'published') {
      const oldPath = `/events/${previousDoc.slug}`

      payload.logger.info(`Revalidating old event at path: ${oldPath}`)

      try {
        const { revalidatePath, revalidateTag } = await import('next/cache')
        revalidatePath(oldPath)
        revalidateTag('events-sitemap')
      } catch {}
    }
  }
  return doc
}

Subdomains

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free