feat: manage event detail fallback copy via payload

This commit is contained in:
syntaxbullet
2026-06-22 12:45:47 +02:00
parent e12d814040
commit 2eef1d8350
4 changed files with 57 additions and 8 deletions

View File

@@ -184,6 +184,21 @@ export const Events: CollectionConfig = {
{ name: 'url', type: 'text', defaultValue: eventDetailContent.heroBackLink.url },
],
},
{
name: 'fallbackEvent',
label: 'Missing event field fallbacks',
type: 'group',
fields: [
{ name: 'title', type: 'text', defaultValue: eventDetailContent.fallbackEvent.title },
{ name: 'date', type: 'text', defaultValue: eventDetailContent.fallbackEvent.date },
{ name: 'time', type: 'text', defaultValue: eventDetailContent.fallbackEvent.time },
{ name: 'location', type: 'text', defaultValue: eventDetailContent.fallbackEvent.location },
{ name: 'venue', type: 'text', defaultValue: eventDetailContent.fallbackEvent.venue },
{ name: 'category', type: 'text', defaultValue: eventDetailContent.fallbackEvent.category },
{ name: 'status', type: 'text', defaultValue: eventDetailContent.fallbackEvent.status },
{ name: 'longDescription', type: 'textarea', defaultValue: eventDetailContent.fallbackEvent.longDescription },
],
},
{
name: 'sections',
label: 'Section labels and CTAs',

View File

@@ -2913,6 +2913,16 @@ export interface Event {
label?: string | null;
url?: string | null;
};
fallbackEvent?: {
title?: string | null;
date?: string | null;
time?: string | null;
location?: string | null;
venue?: string | null;
category?: string | null;
status?: string | null;
longDescription?: string | null;
};
sections?: {
aboutEyebrow?: string | null;
factsEyebrow?: string | null;
@@ -5150,6 +5160,18 @@ export interface EventsSelect<T extends boolean = true> {
label?: T;
url?: T;
};
fallbackEvent?:
| T
| {
title?: T;
date?: T;
time?: T;
location?: T;
venue?: T;
category?: T;
status?: T;
longDescription?: T;
};
sections?:
| T
| {

View File

@@ -27,6 +27,16 @@ export const eventDetailContent = {
label: 'Alle Events',
url: '/presse',
},
fallbackEvent: {
title: 'Event',
date: 'Termin folgt',
time: 'Uhrzeit folgt',
location: 'Bayern',
venue: 'Ort folgt',
category: 'Event',
status: 'geplant',
longDescription: 'Dieses Event wird aus Payload CMS geladen.',
},
sections: {
aboutEyebrow: 'Über die Veranstaltung',
factsEyebrow: 'Eckdaten',

View File

@@ -48,6 +48,7 @@ const getDetailPage = (value: unknown): EventDetailCms => {
updateStyles: asStyleMap(detail.updateStyles, eventDetailContent.updateStyles),
statusStyles: asStyleMap(detail.statusStyles, eventDetailContent.statusStyles),
heroBackLink: { ...eventDetailContent.heroBackLink, ...detail.heroBackLink },
fallbackEvent: { ...eventDetailContent.fallbackEvent, ...detail.fallbackEvent },
sections: { ...eventDetailContent.sections, ...detail.sections },
updatesCopy: { ...eventDetailContent.updates, ...(detail.updatesCopy || detail.updates) },
bottomCta: { ...eventDetailContent.bottomCta, ...detail.bottomCta },
@@ -98,20 +99,21 @@ export default function EventDetail() {
const route = useCmsRoute()
const cmsEvent = route?.collection === 'events' ? route.doc : undefined
const cmsDetail = getDetailPage(cmsEvent?.detailPage)
const fallbackEvent = cmsDetail.fallbackEvent || eventDetailContent.fallbackEvent
const eventFallbackImage = mediaUrl(cmsDetail.fallbackImage, `/images/${eventDetailContent.fallbackImageFilename}`)
const event = getEventBySlug(slug ?? '') || (cmsEvent ? {
slug: String(cmsEvent.slug || slug),
title: String(cmsEvent.title || 'Event'),
title: String(cmsEvent.title || fallbackEvent.title || eventDetailContent.fallbackEvent.title),
subtitle: String(cmsEvent.subtitle || cmsEvent.description || cmsEvent.meta?.description || ''),
date: String(cmsEvent.date || 'Termin folgt'),
time: String(cmsEvent.time || 'Uhrzeit folgt'),
location: String(cmsEvent.location || 'Bayern'),
venue: String(cmsEvent.venue || 'Ort folgt'),
category: String(cmsEvent.category || 'Event'),
status: (cmsEvent.status as BmpEvent['status']) || 'geplant',
date: String(cmsEvent.date || fallbackEvent.date || eventDetailContent.fallbackEvent.date),
time: String(cmsEvent.time || fallbackEvent.time || eventDetailContent.fallbackEvent.time),
location: String(cmsEvent.location || fallbackEvent.location || eventDetailContent.fallbackEvent.location),
venue: String(cmsEvent.venue || fallbackEvent.venue || eventDetailContent.fallbackEvent.venue),
category: String(cmsEvent.category || fallbackEvent.category || eventDetailContent.fallbackEvent.category),
status: ((cmsEvent.status || fallbackEvent.status || eventDetailContent.fallbackEvent.status) as BmpEvent['status']),
img: docImageUrl(cmsEvent, eventFallbackImage),
description: String(cmsEvent.description || cmsEvent.meta?.description || ''),
longDescription: String(cmsEvent.longDescription || cmsEvent.description || cmsEvent.meta?.description || 'Dieses Event wird aus Payload CMS geladen.'),
longDescription: String(cmsEvent.longDescription || cmsEvent.description || cmsEvent.meta?.description || fallbackEvent.longDescription || eventDetailContent.fallbackEvent.longDescription),
eckdaten: Array.isArray(cmsEvent.eckdaten) ? cmsEvent.eckdaten as EventEckdaten[] : [],
updates: Array.isArray(cmsEvent.updates) ? cmsEvent.updates as EventUpdate[] : [],
detailPage: cmsEvent.detailPage,