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
+32
View File
@@ -0,0 +1,32 @@
import type { Field, RelationshipField } from 'payload'
import type { ContentOption } from './types.js'
import { archiveFieldName } from './types.js'
/**
* Builds one relationship field per content collection, pointing at the
* client's Pages collection.
*
* Sits alongside the system-page roles (homepage, privacy policy) because it's
* the same idea: a page referenced by function rather than by slug. The
* assignment is locale-agnostic — one page document — while the resulting path
* is locale-aware, since the page's slug is localized. Assign the "Artykuły"
* page once and you get /pl/artykuly and /en/articles from its own slugs.
*/
export function buildArchiveFields(content: ContentOption, pagesSlug: string): Field[] {
return content.collections.map((collection): RelationshipField => {
const label = collection.label ?? collection.slug
return {
name: archiveFieldName(collection.slug),
type: 'relationship',
admin: {
description: `Page listing ${label}. Its slug becomes the URL segment for entries (e.g. /pl/artykuly/moj-wpis).`,
},
label: `${label} — archive page`,
maxDepth: 1,
relationTo: pagesSlug,
}
})
}