Refine CMS i18n fallback, refresh UI, add consent minimize, seed i18n content

Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
Cursor Agent
2026-01-12 16:10:22 +00:00
parent 683735cc63
commit 6f1ad8eb4d
10 changed files with 244 additions and 81 deletions

View File

@@ -3,6 +3,18 @@ import { slugify } from "../lib/slug";
const prisma = new PrismaClient();
function tiptapParagraph(text: string) {
return {
type: "doc",
content: [
{
type: "paragraph",
content: [{ type: "text", text }],
},
],
};
}
async function main() {
console.log("🌱 Seeding database...");
@@ -11,6 +23,104 @@ async function main() {
await prisma.pageView.deleteMany();
await prisma.project.deleteMany();
// Ensure base site settings & minimal localized CMS defaults (do NOT overwrite existing content).
await prisma.siteSettings.upsert({
where: { id: 1 },
update: {},
create: { id: 1, defaultLocale: "en", locales: ["en", "de"] },
});
async function ensureContentPage(
key: string,
translations: Array<{ locale: "en" | "de"; title: string; contentText: string }>,
) {
const page = await prisma.contentPage.upsert({
where: { key },
update: {},
create: { key, status: "PUBLISHED" },
});
for (const tr of translations) {
await prisma.contentPageTranslation.upsert({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
where: { pageId_locale: { pageId: page.id, locale: tr.locale } } as any,
update: {},
create: {
pageId: page.id,
locale: tr.locale,
title: tr.title,
content: tiptapParagraph(tr.contentText),
},
});
}
}
await ensureContentPage("home-hero", [
{
locale: "en",
title: "Hero",
contentText: "I build fast, secure, self-hosted platforms — and I love clean UX.",
},
{
locale: "de",
title: "Hero",
contentText: "Ich baue schnelle, sichere, selbst gehostete Plattformen — mit sauberem UX.",
},
]);
await ensureContentPage("home-about", [
{
locale: "en",
title: "About",
contentText: "Im a software engineer focused on performance, security, and maintainable systems.",
},
{
locale: "de",
title: "Über mich",
contentText: "Ich bin Software Engineer mit Fokus auf Performance, Security und wartbare Systeme.",
},
]);
await ensureContentPage("home-contact", [
{
locale: "en",
title: "Contact",
contentText: "Want to work together? Send me a message and Ill get back to you.",
},
{
locale: "de",
title: "Kontakt",
contentText: "Lust auf Zusammenarbeit? Schreib mir und ich melde mich zurück.",
},
]);
// These are used by /[locale]/legal-notice and /[locale]/privacy-policy (re-exported pages)
await ensureContentPage("legal-notice", [
{
locale: "en",
title: "Legal notice",
contentText: "Legal notice content can be edited in the CMS per language.",
},
{
locale: "de",
title: "Impressum",
contentText: "Impressum-Inhalt kann im CMS pro Sprache bearbeitet werden.",
},
]);
await ensureContentPage("privacy-policy", [
{
locale: "en",
title: "Privacy policy",
contentText: "Privacy policy content can be edited in the CMS per language.",
},
{
locale: "de",
title: "Datenschutzerklärung",
contentText: "Datenschutzerklärung kann im CMS pro Sprache bearbeitet werden.",
},
]);
// Create real projects
const projects = [
{