105 lines
4.1 KiB
TypeScript
105 lines
4.1 KiB
TypeScript
import { getPayload } from 'payload';
|
|
import configPromise from '../payload.config';
|
|
|
|
const fixHome = async () => {
|
|
const payload = await getPayload({ config: configPromise });
|
|
payload.logger.info('Running missing Home page script...');
|
|
|
|
try {
|
|
for (const loc of ['de', 'en']) {
|
|
const existingHome = await payload.find({
|
|
collection: 'pages',
|
|
where: { slug: { equals: 'home' } },
|
|
locale: loc as any,
|
|
limit: 1,
|
|
});
|
|
|
|
const homeData = {
|
|
title: loc === 'de' ? 'Startseite' : 'Home',
|
|
slug: 'home',
|
|
_status: 'published',
|
|
content: {
|
|
root: {
|
|
type: 'root',
|
|
format: '',
|
|
indent: 0,
|
|
version: 1,
|
|
children: [
|
|
{
|
|
type: 'block',
|
|
format: '',
|
|
version: 2,
|
|
fields: {
|
|
blockType: 'homeHero',
|
|
title: loc === 'de' ? 'DIE EXPERTEN FÜR \nKABELTIEFBAU' : 'THE EXPERTS FOR \nCABLE ENGINEERING',
|
|
subtitle: loc === 'de' ? 'Wir verbinden Infrastruktur mit Präzision. Von Horizontalbohrungen bis zu komplexen Leitungsnetzen.' : 'We connect infrastructure with precision. From horizontal drilling to complex pipe networks.',
|
|
videoUrl: '/assets/dummy-hero.mp4',
|
|
ctaLabel: loc === 'de' ? 'Unternehmen entdecken' : 'Discover Company',
|
|
ctaHref: '#unternehmen',
|
|
secondaryCtaLabel: loc === 'de' ? 'Projekt anfragen' : 'Request Project',
|
|
secondaryCtaHref: `/${loc}/kontakt`
|
|
}
|
|
},
|
|
{
|
|
type: 'block',
|
|
format: '',
|
|
version: 2,
|
|
fields: {
|
|
blockType: 'homeSubCompanyTiles',
|
|
badge: loc === 'de' ? 'Die Gruppe' : 'The Group',
|
|
title: loc === 'de' ? 'Geballte Kompetenz unter einem Dach' : 'Concentrated competence under one roof'
|
|
}
|
|
},
|
|
{
|
|
type: 'block',
|
|
format: '',
|
|
version: 2,
|
|
fields: {
|
|
blockType: 'homeCompetenceBentoGrid',
|
|
badge: loc === 'de' ? 'Leistungsspektrum' : 'Range of Services',
|
|
title: loc === 'de' ? 'Umfassende Lösungen für komplexe Netzwerke' : 'Comprehensive solutions for complex networks',
|
|
ctaLabel: loc === 'de' ? 'Alle Kompetenzen ansehen' : 'View all competences',
|
|
ctaHref: `/${loc}/kompetenzen`
|
|
}
|
|
},
|
|
{
|
|
type: 'block',
|
|
format: '',
|
|
version: 2,
|
|
fields: {
|
|
blockType: 'homeMeetTheTeam',
|
|
title: loc === 'de' ? 'Das sind Ihre Ansprechpartner' : 'Meet our team',
|
|
subtitle: loc === 'de' ? 'Unser Team aus Experten freut sich auf Ihr Projekt.' : 'Our team of experts is looking forward to your project.',
|
|
description: loc === 'de' ? 'Hier finden Sie alle Zertifikate und Ansprechpartner an einem Ort.' : 'Here you can find all certificates and contacts in one place.',
|
|
ctaLabel: loc === 'de' ? 'Zum Kontaktformular' : 'To Contact Form',
|
|
networkLabel: loc === 'de' ? 'Das E-TIB Netzwerk' : 'The E-TIB Network'
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
};
|
|
|
|
if (existingHome.totalDocs === 0) {
|
|
payload.logger.info(`Creating Home page [${loc}]...`);
|
|
await payload.create({ collection: 'pages', locale: loc as any, data: homeData });
|
|
} else {
|
|
await payload.update({ collection: 'pages', id: existingHome.docs[0].id, locale: loc as any, data: homeData });
|
|
}
|
|
}
|
|
|
|
payload.logger.info('✅ Home page created successfully!');
|
|
process.exit(0);
|
|
} catch (err: any) {
|
|
payload.logger.error('❌ Missing Home page script failed!');
|
|
if (err.data) {
|
|
payload.logger.error(JSON.stringify(err.data, null, 2));
|
|
} else {
|
|
payload.logger.error(err.stack || err.message || err);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
};
|
|
|
|
fixHome();
|