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

@@ -9,6 +9,7 @@ import { imageHero1 } from './image-hero-1'
import { post1 } from './post-1'
import { post2 } from './post-2'
import { post3 } from './post-3'
import { defaultFooterData, defaultHeaderData } from '@/spa/cmsNavigation'
const collections: CollectionSlug[] = [
'categories',
@@ -48,9 +49,7 @@ export const seed = async ({
globals.map((global) =>
payload.updateGlobal({
slug: global,
data: {
navItems: [],
},
data: {},
depth: 0,
context: {
disableRevalidate: true,
@@ -217,60 +216,17 @@ export const seed = async ({
payload.logger.info(`— Seeding globals...`)
const { logo: _headerLogo, ...headerSeedData } = defaultHeaderData
const { logo: _footerLogo, partnerLogos: _partnerLogos, ...footerSeedData } = defaultFooterData
await Promise.all([
payload.updateGlobal({
slug: 'header',
data: {
navItems: [
{
link: {
type: 'custom',
label: 'Posts',
url: '/posts',
},
},
{
link: {
type: 'reference',
label: 'Contact',
reference: {
relationTo: 'pages',
value: contactPage.id,
},
},
},
],
},
data: headerSeedData as any,
}),
payload.updateGlobal({
slug: 'footer',
data: {
navItems: [
{
link: {
type: 'custom',
label: 'Admin',
url: '/admin',
},
},
{
link: {
type: 'custom',
label: 'Source Code',
newTab: true,
url: 'https://github.com/payloadcms/payload/tree/3.x/templates/website',
},
},
{
link: {
type: 'custom',
label: 'Payload',
newTab: true,
url: 'https://payloadcms.com/',
},
},
],
},
data: footerSeedData as any,
}),
])