Revalidate the site layout when a global is saved
buildGlobalRevalidateHook + ipalKit({ revalidatePath }) wires it into the
plugin's globals; menus, consent texts and analytics IDs no longer stay
stale for the whole ISR window.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7c05a1dba9
commit
7967453f57
+10
-2
@@ -17,6 +17,7 @@ import { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'
|
||||
import { buildLocalizationConfig, validateI18nConfig } from './modules/i18n/index.js'
|
||||
import { buildSystemPagesFields } from './modules/pages/index.js'
|
||||
import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo/index.js'
|
||||
import { buildGlobalRevalidateHook } from './modules/hooks/buildRevalidateHook.js'
|
||||
import { buildIndexNowHook } from './modules/seo/indexNow.js'
|
||||
import { buildStatsCollection, buildStatsEndpoint } from './modules/stats/index.js'
|
||||
|
||||
@@ -229,8 +230,7 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
: []),
|
||||
]
|
||||
|
||||
config.globals = [
|
||||
...(config.globals ?? []),
|
||||
const pluginGlobals = [
|
||||
buildSiteSettings({
|
||||
additionalFields: options.siteSettingsFields,
|
||||
...(options.pages ? { constructionFields: buildConstructionFields(options.pages.slug) } : {}),
|
||||
@@ -241,6 +241,14 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
buildCookieSettings(),
|
||||
buildNotifications(),
|
||||
]
|
||||
// A global feeds every page's layout — revalidate the site on save.
|
||||
const revalidateGlobal = options.revalidatePath ? buildGlobalRevalidateHook({ revalidatePath: options.revalidatePath }) : null
|
||||
config.globals = [
|
||||
...(config.globals ?? []),
|
||||
...(revalidateGlobal
|
||||
? pluginGlobals.map((g) => ({ ...g, hooks: { ...g.hooks, afterChange: [...(g.hooks?.afterChange ?? []), revalidateGlobal] } }))
|
||||
: pluginGlobals),
|
||||
]
|
||||
|
||||
config.endpoints = [...(config.endpoints ?? []), testEmailEndpoint]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user