feat: manage datenschutz page via payload
This commit is contained in:
81
src/collections/Pages/datenschutzFields.ts
Normal file
81
src/collections/Pages/datenschutzFields.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import type { Field } from 'payload'
|
||||
|
||||
import { datenschutzContent } from '@/spa/datenschutzContent'
|
||||
|
||||
const text = (name: string, label: string, defaultValue?: string): Field => ({
|
||||
name,
|
||||
type: 'text',
|
||||
label,
|
||||
defaultValue,
|
||||
})
|
||||
|
||||
const textarea = (name: string, label: string, defaultValue?: string): Field => ({
|
||||
name,
|
||||
type: 'textarea',
|
||||
label,
|
||||
defaultValue,
|
||||
})
|
||||
|
||||
const sectionAdmin = (description: string) => ({
|
||||
description,
|
||||
initCollapsed: true,
|
||||
})
|
||||
|
||||
export const datenschutzFields: Field[] = [
|
||||
{
|
||||
name: 'datenschutz',
|
||||
label: 'Datenschutz page content',
|
||||
type: 'group',
|
||||
admin: {
|
||||
description:
|
||||
'Edit the Datenschutz page content. Legal section body blocks are stored as JSON so nested paragraphs, lists, notices, addresses, and subsections can keep their frontend order.',
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'hero',
|
||||
label: '01 · Hero',
|
||||
type: 'group',
|
||||
admin: sectionAdmin('Top legal page heading and description line.'),
|
||||
fields: [
|
||||
text('backLabel', 'Back link label', datenschutzContent.hero.backLabel),
|
||||
text('eyebrow', 'Eyebrow', datenschutzContent.hero.eyebrow),
|
||||
textarea('heading', 'Heading', datenschutzContent.hero.heading),
|
||||
textarea('descriptionHtml', 'Description HTML', datenschutzContent.hero.descriptionHtml),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'navigation',
|
||||
label: '02 · Side navigation',
|
||||
type: 'group',
|
||||
admin: sectionAdmin('Sticky table-of-contents title and related legal-page link.'),
|
||||
fields: [
|
||||
text('tocTitle', 'TOC title', datenschutzContent.navigation.tocTitle),
|
||||
text('sideLinkLabel', 'Side link label', datenschutzContent.navigation.sideLinkLabel),
|
||||
text('sideLinkUrl', 'Side link URL', datenschutzContent.navigation.sideLinkUrl),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'sections',
|
||||
label: '03 · Legal sections',
|
||||
type: 'array',
|
||||
dbName: 'data_sections',
|
||||
admin: sectionAdmin('Each section controls one heading, table-of-contents label, and ordered JSON body blocks.'),
|
||||
defaultValue: datenschutzContent.sections,
|
||||
fields: [
|
||||
text('id', 'Anchor ID'),
|
||||
text('tocLabel', 'TOC label'),
|
||||
text('title', 'Section title'),
|
||||
{
|
||||
name: 'items',
|
||||
label: 'Content blocks JSON',
|
||||
type: 'json',
|
||||
admin: {
|
||||
description:
|
||||
'Array of blocks: paragraph, legal, address, list, or subsection. Paragraph/legal blocks use HTML strings for inline links.',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
@@ -10,6 +10,7 @@ import { MediaBlock } from '../../blocks/MediaBlock/config'
|
||||
import { hero } from '@/heros/config'
|
||||
import { aboutFields } from './aboutFields'
|
||||
import { contactFields } from './contactFields'
|
||||
import { datenschutzFields } from './datenschutzFields'
|
||||
import { homeFields } from './homeFields'
|
||||
import { impressumFields } from './impressumFields'
|
||||
import { participationFields } from './participationFields'
|
||||
@@ -66,12 +67,21 @@ const isImpressumPage = (_: unknown, siblingData?: { slug?: string; spaPath?: st
|
||||
return spaPath === '/impressum' || slug === 'impressum' || title === 'impressum'
|
||||
}
|
||||
|
||||
const isDatenschutzPage = (_: unknown, siblingData?: { slug?: string; spaPath?: string; title?: string }) => {
|
||||
const slug = siblingData?.slug
|
||||
const spaPath = siblingData?.spaPath
|
||||
const title = siblingData?.title?.toLowerCase()
|
||||
|
||||
return spaPath === '/datenschutz' || slug === 'datenschutz' || title === 'datenschutz'
|
||||
}
|
||||
|
||||
const isManagedSpaPage = (_: unknown, siblingData?: { slug?: string; spaPath?: string; title?: string }) =>
|
||||
isHomePage(undefined, siblingData) ||
|
||||
isContactPage(undefined, siblingData) ||
|
||||
isParticipationPage(undefined, siblingData) ||
|
||||
isAboutPage(undefined, siblingData) ||
|
||||
isImpressumPage(undefined, siblingData)
|
||||
isImpressumPage(undefined, siblingData) ||
|
||||
isDatenschutzPage(undefined, siblingData)
|
||||
|
||||
export const Pages: CollectionConfig<'pages'> = {
|
||||
slug: 'pages',
|
||||
@@ -174,6 +184,13 @@ export const Pages: CollectionConfig<'pages'> = {
|
||||
fields: impressumFields,
|
||||
label: 'Impressum Page',
|
||||
},
|
||||
{
|
||||
admin: {
|
||||
condition: (data) => isDatenschutzPage(undefined, data),
|
||||
},
|
||||
fields: datenschutzFields,
|
||||
label: 'Datenschutz Page',
|
||||
},
|
||||
{
|
||||
name: 'meta',
|
||||
label: 'SEO',
|
||||
|
||||
Reference in New Issue
Block a user