Add migration scripts and preload participation awards script
- Created migration index file to manage database migrations. - Added script to preload participation awards and related blog posts into the CMS. - Introduced new types and default data for application phases. - Added award articles data structure for the upcoming awards.
This commit is contained in:
@@ -5,6 +5,7 @@ import { draftMode } from 'next/headers'
|
||||
import { notFound } from 'next/navigation'
|
||||
|
||||
import NextApp from '@/spa/NextApp'
|
||||
import { normalizeApplicationPhaseData, type SpaApplicationPhaseData } from '@/spa/applicationPhase'
|
||||
import { normalizeFooterData, normalizeHeaderData } from '@/spa/cmsNavigation'
|
||||
import type { CmsRouteDoc } from '@/spa/cmsRoute'
|
||||
import { normalizeSiteSettings, type SpaSiteSettingsData } from '@/spa/siteSettings'
|
||||
@@ -69,16 +70,34 @@ async function findList(payload: Awaited<ReturnType<typeof getPayload>>, collect
|
||||
return result.docs
|
||||
}
|
||||
|
||||
async function findHomePage(payload: Awaited<ReturnType<typeof getPayload>>, draft: boolean) {
|
||||
const result = await payload.find({
|
||||
collection: 'pages',
|
||||
depth: 1,
|
||||
draft,
|
||||
overrideAccess: draft,
|
||||
limit: 1,
|
||||
pagination: false,
|
||||
where: {
|
||||
or: [{ spaPath: { equals: '/' } }, { slug: { equals: 'startseite' } }, { slug: { equals: 'home' } }],
|
||||
},
|
||||
})
|
||||
|
||||
return result.docs[0]
|
||||
}
|
||||
|
||||
export default async function Page({ params }: Args) {
|
||||
const { slug = [] } = await params
|
||||
const pathname = `/${slug.join('/')}`.replace(/\/$/, '') || '/'
|
||||
const payload = await getPayload({ config: configPromise })
|
||||
const { isEnabled: draft } = await draftMode()
|
||||
const [header, footer, siteSettings, route, preistraeger, events, posts] = await Promise.all([
|
||||
const [header, footer, siteSettings, applicationPhase, route, homePage, preistraeger, events, posts] = await Promise.all([
|
||||
payload.findGlobal({ slug: 'header', depth: 1 }).catch(() => undefined),
|
||||
payload.findGlobal({ slug: 'footer', depth: 1 }).catch(() => undefined),
|
||||
payload.findGlobal({ slug: 'site-settings', depth: 1 }).catch(() => undefined),
|
||||
payload.findGlobal({ slug: 'application-phase', depth: 0 }).catch(() => undefined),
|
||||
findRouteDoc(payload, pathname, draft),
|
||||
findHomePage(payload, draft).catch(() => undefined),
|
||||
findList(payload, 'preistraeger', draft).catch(() => []),
|
||||
findList(payload, 'events', draft).catch(() => []),
|
||||
findList(payload, 'posts', draft).catch(() => []),
|
||||
@@ -92,10 +111,12 @@ export default async function Page({ params }: Args) {
|
||||
header={normalizeHeaderData(header)}
|
||||
footer={normalizeFooterData(footer)}
|
||||
siteSettings={normalizeSiteSettings(siteSettings as Partial<SpaSiteSettingsData> | undefined)}
|
||||
applicationPhase={normalizeApplicationPhaseData(applicationPhase as Partial<SpaApplicationPhaseData> | undefined)}
|
||||
cmsRoute={{
|
||||
collection: route.collection,
|
||||
doc: route.doc as unknown as CmsRouteDoc,
|
||||
lists: {
|
||||
pages: homePage ? [homePage as unknown as CmsRouteDoc] : [],
|
||||
preistraeger: preistraeger as unknown as CmsRouteDoc[],
|
||||
events: events as unknown as CmsRouteDoc[],
|
||||
posts: posts as unknown as CmsRouteDoc[],
|
||||
|
||||
Reference in New Issue
Block a user