feat: manage press index via payload

This commit is contained in:
syntaxbullet
2026-06-22 11:10:59 +02:00
parent aecdb65a14
commit 27b29a8a7a
7 changed files with 600 additions and 130 deletions

View File

@@ -15,6 +15,7 @@ import { homeFields } from './homeFields'
import { impressumFields } from './impressumFields'
import { participationFields } from './participationFields'
import { preistraegerIndexFields } from './preistraegerIndexFields'
import { pressIndexFields } from './pressIndexFields'
import { slugField } from 'payload'
import { populatePublishedAt } from '../../hooks/populatePublishedAt'
import { generatePreviewPath } from '../../utilities/generatePreviewPath'
@@ -84,6 +85,14 @@ const isPreistraegerIndexPage = (_: unknown, siblingData?: { slug?: string; spaP
return spaPath === '/preistraeger' || slug === 'preistraeger' || title === 'preisträger' || title === 'preistraeger'
}
const isPressIndexPage = (_: unknown, siblingData?: { slug?: string; spaPath?: string; title?: string }) => {
const slug = siblingData?.slug
const spaPath = siblingData?.spaPath
const title = siblingData?.title?.toLowerCase()
return spaPath === '/presse' || slug === 'presse' || slug === 'press' || title === 'presse' || title === 'press'
}
const isManagedSpaPage = (_: unknown, siblingData?: { slug?: string; spaPath?: string; title?: string }) =>
isHomePage(undefined, siblingData) ||
isContactPage(undefined, siblingData) ||
@@ -91,7 +100,8 @@ const isManagedSpaPage = (_: unknown, siblingData?: { slug?: string; spaPath?: s
isAboutPage(undefined, siblingData) ||
isImpressumPage(undefined, siblingData) ||
isDatenschutzPage(undefined, siblingData) ||
isPreistraegerIndexPage(undefined, siblingData)
isPreistraegerIndexPage(undefined, siblingData) ||
isPressIndexPage(undefined, siblingData)
export const Pages: CollectionConfig<'pages'> = {
slug: 'pages',
@@ -208,6 +218,13 @@ export const Pages: CollectionConfig<'pages'> = {
fields: preistraegerIndexFields,
label: 'Preisträger Index Page',
},
{
admin: {
condition: (data) => isPressIndexPage(undefined, data),
},
fields: pressIndexFields,
label: 'Press Index Page',
},
{
name: 'meta',
label: 'SEO',

View File

@@ -0,0 +1,152 @@
import type { Field } from 'payload'
import { pressIndexContent } from '@/spa/pressIndexContent'
const uploadField = (name: string, label: string, description?: string): Field => ({
name,
type: 'upload',
relationTo: 'media',
label,
admin: description ? { description } : undefined,
})
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,
})
const eventFields: Field[] = [
text('title', 'Title'),
text('date', 'Date'),
text('location', 'Location'),
text('cat', 'Category'),
text('status', 'Status'),
text('img', 'Image URL or path'),
textarea('desc', 'Description'),
text('slug', 'Route'),
]
const newsFields: Field[] = [
text('title', 'Title'),
textarea('excerpt', 'Excerpt'),
text('cat', 'Category'),
text('img', 'Image URL or path'),
text('slug', 'Route'),
]
export const pressIndexFields: Field[] = [
{
name: 'pressIndex',
label: 'Press index page content',
type: 'group',
admin: {
description:
'Edit the Presse listing page chrome. Event and news records are managed through Events and Presse collections; fallback cards remain editable here.',
},
fields: [
{
name: 'hero',
label: '01 · Hero',
type: 'group',
admin: sectionAdmin('Hero image, eyebrow, heading, and intro copy.'),
fields: [
uploadField('image', 'Hero image', `Current frontend image: /images/${pressIndexContent.hero.imageFilename}`),
text('imageAlt', 'Image alt text', pressIndexContent.hero.imageAlt),
text('eyebrow', 'Eyebrow', pressIndexContent.hero.eyebrow),
textarea('heading', 'Heading', pressIndexContent.hero.heading),
textarea('description', 'Description', pressIndexContent.hero.description),
],
},
{
name: 'events',
label: '02 · Events section',
type: 'group',
admin: sectionAdmin('Section header, labels, and fallback event rows.'),
fields: [
text('eyebrow', 'Eyebrow', pressIndexContent.events.eyebrow),
textarea('heading', 'Heading', pressIndexContent.events.heading),
textarea('description', 'Description', pressIndexContent.events.description),
text('detailLabel', 'Detail link label', pressIndexContent.events.detailLabel),
text('openStatusLabel', 'Open status label', pressIndexContent.events.openStatusLabel),
{
name: 'fallbackItems',
label: 'Fallback event rows',
type: 'array',
dbName: 'press_events_fb',
defaultValue: pressIndexContent.events.fallbackItems,
fields: eventFields,
},
],
},
{
name: 'news',
label: '03 · Newsroom section',
type: 'group',
admin: sectionAdmin('Section header, read-more label, and fallback news cards.'),
fields: [
text('eyebrow', 'Eyebrow', pressIndexContent.news.eyebrow),
textarea('heading', 'Heading', pressIndexContent.news.heading),
textarea('description', 'Description', pressIndexContent.news.description),
text('readMoreLabel', 'Read more label', pressIndexContent.news.readMoreLabel),
{
name: 'fallbackItems',
label: 'Fallback news cards',
type: 'array',
dbName: 'press_news_fb',
defaultValue: pressIndexContent.news.fallbackItems,
fields: newsFields,
},
],
},
{
name: 'downloads',
label: '04 · Press material and contact',
type: 'group',
admin: sectionAdmin('Download button and press contact block.'),
fields: [
text('eyebrow', 'Eyebrow', pressIndexContent.downloads.eyebrow),
textarea('heading', 'Heading', pressIndexContent.downloads.heading),
textarea('description', 'Description', pressIndexContent.downloads.description),
text('kitLabel', 'Kit label', pressIndexContent.downloads.kitLabel),
text('kitMeta', 'Kit metadata', pressIndexContent.downloads.kitMeta),
text('kitUrl', 'Kit URL', pressIndexContent.downloads.kitUrl),
text('kitDownloadName', 'Kit download filename', pressIndexContent.downloads.kitDownloadName),
text('contactEyebrow', 'Contact eyebrow', pressIndexContent.downloads.contactEyebrow),
text('contactName', 'Contact name', pressIndexContent.downloads.contactName),
textarea('contactLines', 'Contact lines', pressIndexContent.downloads.contactLines),
],
},
{
name: 'accreditation',
label: '05 · Accreditation form copy',
type: 'group',
admin: sectionAdmin('Labels and success state for the press accreditation form.'),
fields: [
text('eyebrow', 'Eyebrow', pressIndexContent.accreditation.eyebrow),
textarea('heading', 'Heading', pressIndexContent.accreditation.heading),
textarea('description', 'Description', pressIndexContent.accreditation.description),
text('mediumLabel', 'Medium label', pressIndexContent.accreditation.mediumLabel),
text('nameLabel', 'Name label', pressIndexContent.accreditation.nameLabel),
text('emailLabel', 'Email label', pressIndexContent.accreditation.emailLabel),
text('submitLabel', 'Submit label', pressIndexContent.accreditation.submitLabel),
text('successHeading', 'Success heading', pressIndexContent.accreditation.successHeading),
textarea('successMessage', 'Success message', pressIndexContent.accreditation.successMessage),
],
},
],
},
]