feat: connect header and footer to cms as globals

This commit is contained in:
syntaxbullet
2026-06-16 14:25:58 +02:00
parent 6b395e5735
commit cde2164773
13 changed files with 842 additions and 456 deletions

View File

@@ -1,4 +1,10 @@
import configPromise from '@payload-config'
import { getPayload } from 'payload'
import NextApp from '@/spa/NextApp'
import { normalizeFooterData, normalizeHeaderData } from '@/spa/cmsNavigation'
export const dynamic = 'force-dynamic'
type Args = {
params: Promise<{ slug?: string[] }>
@@ -7,6 +13,11 @@ type Args = {
export default async function Page({ params }: Args) {
const { slug = [] } = await params
const pathname = `/${slug.join('/')}`.replace(/\/$/, '') || '/'
const payload = await getPayload({ config: configPromise })
const [header, footer] = await Promise.all([
payload.findGlobal({ slug: 'header', depth: 1 }).catch(() => undefined),
payload.findGlobal({ slug: 'footer', depth: 1 }).catch(() => undefined),
])
return <NextApp pathname={pathname} />
return <NextApp pathname={pathname} header={normalizeHeaderData(header)} footer={normalizeFooterData(footer)} />
}