Files
bmp-website-2026/src/scripts/preload-globals-cms.ts
syntaxbullet bd2e99ca91 feat: implement newsletter subscription feature with new forms and database structure
- Added new newsletter subscription functionality to the participation page.
- Created a new `NewsletterForm` component to handle user subscriptions.
- Introduced `NewsletterSubscriptions` collection to manage subscriptions in the database.
- Developed migration script to set up necessary database tables and fields for the newsletter feature.
- Refactored participation content to remove deprecated newsletter phase data and integrate new structure.
- Updated the `Participation` page to utilize the new newsletter form and handle different application phases.
2026-07-13 13:37:03 +02:00

79 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'dotenv/config'
import config from '@payload-config'
import { getPayload } from 'payload'
import { mediaByFilename } from './mediaByFilename'
import { defaultApplicationPhaseData } from '@/spa/applicationPhase'
import { defaultFooterData, defaultHeaderData } from '@/spa/cmsNavigation'
import { defaultNewsletterFormData } from '@/spa/newsletterForm'
import { defaultSiteSettings } from '@/spa/siteSettings'
async function main() {
const payload = await getPayload({ config })
const [logo, ewifLogo, partnerLogos, skylineImage] = await Promise.all([
mediaByFilename(payload, 'bmp-logo.png'),
mediaByFilename(payload, 'ewif-logo.png'),
mediaByFilename(payload, 'partner-logos.png'),
mediaByFilename(payload, 'munich-skyline.jpg'),
])
const { logo: _headerLogo, ...headerData } = defaultHeaderData
const { logo: _footerLogo, partnerLogos: _defaultPartnerLogos, ...footerData } = defaultFooterData
const { skylineImageUrl: _skylineImageUrl, ...siteSettingsData } = defaultSiteSettings
await Promise.all([
payload.updateGlobal({
slug: 'header',
context: { disableRevalidate: true },
data: {
...headerData,
logo,
} as never,
}),
payload.updateGlobal({
slug: 'footer',
context: { disableRevalidate: true },
data: {
...footerData,
logo,
partnerLogos: [
{ alt: 'EWIF – Europäisches Wirtschaftsforum', image: ewifLogo },
{
alt: 'Hochschule für angewandtes Management · Gipfeldialog Altaussee',
image: partnerLogos,
},
].filter((item) => item.image),
} as never,
}),
payload.updateGlobal({
slug: 'site-settings',
context: { disableRevalidate: true },
data: {
...siteSettingsData,
skylineImage,
} as never,
}),
payload.updateGlobal({
slug: 'application-phase',
context: { disableRevalidate: true },
data: defaultApplicationPhaseData as never,
}),
payload.updateGlobal({
slug: 'newsletter-form',
context: { disableRevalidate: true },
data: defaultNewsletterFormData as never,
}),
])
payload.logger.info('Preloaded global CMS settings.')
await payload.destroy()
process.exit(0)
}
main().catch((error) => {
console.error(error)
process.exit(1)
})