import type { CollectionConfig } from 'payload' import { adminOrEditor, buildNoindexField, buildPreventDeleteSystemPage, buildRevalidateHook, buildSlugField, buildSummaryField, rowLabel, trackSlugHistoryHook, } from '@intecion/ipal-kit' import { revalidatePath } from 'next/cache' import { pageBlocks } from '@/blocks/configs' import { i18nConfig } from '@/i18n.config' const revalidate = buildRevalidateHook({ config: i18nConfig, revalidatePath }) export const Pages: CollectionConfig = { slug: 'pages', admin: { defaultColumns: ['title', 'slug', 'updatedAt'], useAsTitle: 'title' }, // write rules of its own: Payload's default is "any signed-in account" — a visitor login collection would reach it (security.md "Visitor accounts") access: { create: adminOrEditor, delete: adminOrEditor, read: () => true, update: adminOrEditor }, fields: [ { name: 'title', type: 'text', localized: true, required: true }, buildSlugField({ from: 'title' }), { name: 'layout', type: 'blocks', blocks: pageBlocks, minRows: 1 }, buildSummaryField(), // aiSummary — GEO (llms.txt, MCP) buildNoindexField(), { name: 'slugHistory', type: 'array', admin: { components: rowLabel('slug', 'Old address'), readOnly: true }, fields: [{ name: 'slug', type: 'text' }], labels: { plural: 'Old addresses', singular: 'Old address' } }, ], hooks: { afterChange: [revalidate.afterChange], afterDelete: [revalidate.afterDelete], beforeChange: [trackSlugHistoryHook], beforeDelete: [buildPreventDeleteSystemPage({ settingsSlug: 'site-settings' })], }, }