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
+45
View File
@@ -0,0 +1,45 @@
import type { Field, Plugin } from 'payload'
import { seoPlugin } from '@payloadcms/plugin-seo'
import type { SeoOption } from './types.js'
type BuildSeoPluginArgs = {
seo: SeoOption
/** Upload collection slug for the meta image (typically 'media'). */
uploadsCollection?: string
}
/**
* Escape hatch from automatic title composition: whatever is typed here becomes
* the entire title — no site name, no separator. Useful on a home page, where
* composing would produce "Intecion Software | Intecion Software".
*/
const titleOverrideField: Field = {
name: 'titleOverride',
type: 'text',
admin: {
description:
'Use this exact text as the browser-tab title — no site name, no separator. Leave empty to compose the title automatically.',
},
localized: true,
}
/**
* Configures @payloadcms/plugin-seo from IPAL's SeoOption.
*
* Adds the `meta` field group (title, description, image) to the client's
* chosen collections. tabbedUI is intentionally NOT used — it merges tabs by
* inspecting the first field, which breaks when other plugins/fields (roles,
* slug) already sit in the collection, leaving an empty SEO tab. Instead the
* SEO UI fields are injected into a controlled tab by injectSeoTabs.
*/
export function buildSeoPlugin({ seo, uploadsCollection = 'media' }: BuildSeoPluginArgs): Plugin {
return seoPlugin({
collections: seo.collections,
fields: ({ defaultFields }) => [...defaultFields, titleOverrideField, ...(seo.fields ?? [])],
uploadsCollection,
...(seo.generateTitle && { generateTitle: seo.generateTitle }),
...(seo.generateDescription && { generateDescription: seo.generateDescription }),
})
}