feat: manage preistraeger index via payload
This commit is contained in:
@@ -14,6 +14,7 @@ import { datenschutzFields } from './datenschutzFields'
|
||||
import { homeFields } from './homeFields'
|
||||
import { impressumFields } from './impressumFields'
|
||||
import { participationFields } from './participationFields'
|
||||
import { preistraegerIndexFields } from './preistraegerIndexFields'
|
||||
import { slugField } from 'payload'
|
||||
import { populatePublishedAt } from '../../hooks/populatePublishedAt'
|
||||
import { generatePreviewPath } from '../../utilities/generatePreviewPath'
|
||||
@@ -75,13 +76,22 @@ const isDatenschutzPage = (_: unknown, siblingData?: { slug?: string; spaPath?:
|
||||
return spaPath === '/datenschutz' || slug === 'datenschutz' || title === 'datenschutz'
|
||||
}
|
||||
|
||||
const isPreistraegerIndexPage = (_: unknown, siblingData?: { slug?: string; spaPath?: string; title?: string }) => {
|
||||
const slug = siblingData?.slug
|
||||
const spaPath = siblingData?.spaPath
|
||||
const title = siblingData?.title?.toLowerCase()
|
||||
|
||||
return spaPath === '/preistraeger' || slug === 'preistraeger' || title === 'preisträger' || title === 'preistraeger'
|
||||
}
|
||||
|
||||
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) ||
|
||||
isDatenschutzPage(undefined, siblingData)
|
||||
isDatenschutzPage(undefined, siblingData) ||
|
||||
isPreistraegerIndexPage(undefined, siblingData)
|
||||
|
||||
export const Pages: CollectionConfig<'pages'> = {
|
||||
slug: 'pages',
|
||||
@@ -191,6 +201,13 @@ export const Pages: CollectionConfig<'pages'> = {
|
||||
fields: datenschutzFields,
|
||||
label: 'Datenschutz Page',
|
||||
},
|
||||
{
|
||||
admin: {
|
||||
condition: (data) => isPreistraegerIndexPage(undefined, data),
|
||||
},
|
||||
fields: preistraegerIndexFields,
|
||||
label: 'Preisträger Index Page',
|
||||
},
|
||||
{
|
||||
name: 'meta',
|
||||
label: 'SEO',
|
||||
|
||||
116
src/collections/Pages/preistraegerIndexFields.ts
Normal file
116
src/collections/Pages/preistraegerIndexFields.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import type { Field } from 'payload'
|
||||
|
||||
import { preistraegerIndexContent } from '@/spa/preistraegerIndexContent'
|
||||
|
||||
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 ctaGroup = (name: string, label: string, labelDefault: string, urlDefault: string): Field => ({
|
||||
name,
|
||||
label,
|
||||
type: 'group',
|
||||
fields: [text('label', 'Label', labelDefault), text('url', 'URL', urlDefault)],
|
||||
})
|
||||
|
||||
const sectionAdmin = (description: string) => ({
|
||||
description,
|
||||
initCollapsed: true,
|
||||
})
|
||||
|
||||
export const preistraegerIndexFields: Field[] = [
|
||||
{
|
||||
name: 'preistraegerIndex',
|
||||
label: 'Preisträger index page content',
|
||||
type: 'group',
|
||||
admin: {
|
||||
description:
|
||||
'Edit the Preisträger listing page chrome. Individual winner cards are managed through the Preisträger collection.',
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'hero',
|
||||
label: '01 · Hero image',
|
||||
type: 'group',
|
||||
admin: sectionAdmin('Large image above the filters. Upload an image or keep the migrated URL fallback.'),
|
||||
fields: [
|
||||
uploadField('image', 'Hero image'),
|
||||
text('imageUrl', 'Fallback image URL', preistraegerIndexContent.hero.imageUrl),
|
||||
text('imageAlt', 'Image alt text', preistraegerIndexContent.hero.imageAlt),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'breadcrumb',
|
||||
label: '02 · Breadcrumb bar',
|
||||
type: 'group',
|
||||
admin: sectionAdmin('Small page label below the image.'),
|
||||
fields: [text('label', 'Label', preistraegerIndexContent.breadcrumb.label)],
|
||||
},
|
||||
{
|
||||
name: 'filters',
|
||||
label: '03 · Filters',
|
||||
type: 'group',
|
||||
admin: sectionAdmin('Filter placeholders, toggle label, and reset label.'),
|
||||
fields: [
|
||||
text('categoryPlaceholder', 'Category placeholder', preistraegerIndexContent.filters.categoryPlaceholder),
|
||||
text('searchPlaceholder', 'Search placeholder', preistraegerIndexContent.filters.searchPlaceholder),
|
||||
textarea('storyHeading', 'Story heading', preistraegerIndexContent.filters.storyHeading),
|
||||
text('mediaIcon', 'Media icon', preistraegerIndexContent.filters.mediaIcon),
|
||||
text('mediaLabel', 'Media label', preistraegerIndexContent.filters.mediaLabel),
|
||||
text('resetLabel', 'Reset label', preistraegerIndexContent.filters.resetLabel),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'count',
|
||||
label: '04 · Count bar',
|
||||
type: 'group',
|
||||
admin: sectionAdmin('Label after the filtered result count.'),
|
||||
fields: [text('label', 'Count label', preistraegerIndexContent.count.label)],
|
||||
},
|
||||
{
|
||||
name: 'empty',
|
||||
label: '05 · Empty state',
|
||||
type: 'group',
|
||||
admin: sectionAdmin('Message when filters return no winners.'),
|
||||
fields: [textarea('message', 'Empty message', preistraegerIndexContent.empty.message)],
|
||||
},
|
||||
{
|
||||
name: 'card',
|
||||
label: '06 · Winner cards',
|
||||
type: 'group',
|
||||
admin: sectionAdmin('Hover label shown on winner cards.'),
|
||||
fields: [text('hoverLabel', 'Hover label', preistraegerIndexContent.card.hoverLabel)],
|
||||
},
|
||||
{
|
||||
name: 'cta',
|
||||
label: '07 · Bottom CTA',
|
||||
type: 'group',
|
||||
admin: sectionAdmin('Bottom application and membership CTA.'),
|
||||
fields: [
|
||||
textarea('text', 'CTA text', preistraegerIndexContent.cta.text),
|
||||
ctaGroup('primaryCta', 'Primary CTA', preistraegerIndexContent.cta.primaryCta.label, preistraegerIndexContent.cta.primaryCta.url),
|
||||
text('secondaryPrefix', 'Secondary prefix', preistraegerIndexContent.cta.secondaryPrefix),
|
||||
ctaGroup('secondaryCta', 'Secondary CTA', preistraegerIndexContent.cta.secondaryCta.label, preistraegerIndexContent.cta.secondaryCta.url),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
Reference in New Issue
Block a user