init commit for iPAL-kit plugin

This commit is contained in:
2026-07-18 20:30:23 +02:00
parent 10638127a9
commit 5733a9c8bf
119 changed files with 6892 additions and 411 deletions
+38
View File
@@ -0,0 +1,38 @@
import type { Config } from 'payload'
import type { SeoOption } from './types.js'
import { buildAutoFillMetaHook } from './autoFillMeta.js'
/**
* Injects the auto-fill meta hook into every SEO-enabled collection.
*
* Runs after @payloadcms/plugin-seo has added the meta group, appending a
* beforeChange hook that fills empty meta from document content. Existing
* hooks are preserved (plugin hook runs last, so editor input and other hooks
* win first).
*/
export function injectAutoFillMeta(config: Config, seo: SeoOption): Config {
// autoFill disabled explicitly — leave collections untouched
if (seo.autoFill === false) {
return config
}
const hook = buildAutoFillMetaHook(seo.autoFill)
return {
...config,
collections: (config.collections ?? []).map((collection) => {
if (!seo.collections.includes(collection.slug)) {
return collection
}
return {
...collection,
hooks: {
...collection.hooks,
beforeChange: [...(collection.hooks?.beforeChange ?? []), hook],
},
}
}),
}
}