ssr:false caused sections to only render client-side, making them invisible if any JS error occurred. Keep dynamic() for code-splitting but allow server-side rendering. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
96 lines
2.5 KiB
TypeScript
96 lines
2.5 KiB
TypeScript
"use client";
|
|
|
|
/**
|
|
* Transitional Wrapper für bestehende Components
|
|
* Nutzt direkt JSON Messages statt komplexe Translation-Loader
|
|
*/
|
|
|
|
import { NextIntlClientProvider } from 'next-intl';
|
|
import dynamic from 'next/dynamic';
|
|
import type {
|
|
AboutTranslations,
|
|
ProjectsTranslations,
|
|
ContactTranslations,
|
|
FooterTranslations,
|
|
} from '@/types/translations';
|
|
import enMessages from '@/messages/en.json';
|
|
import deMessages from '@/messages/de.json';
|
|
|
|
// Lazy-load below-fold sections (code-split but still SSR)
|
|
const About = dynamic(() => import('./About'));
|
|
const Projects = dynamic(() => import('./Projects'));
|
|
const Contact = dynamic(() => import('./Contact'));
|
|
const Footer = dynamic(() => import('./Footer'));
|
|
|
|
const messageMap = { en: enMessages, de: deMessages };
|
|
|
|
function getNormalizedLocale(locale: string): 'en' | 'de' {
|
|
return locale.startsWith('de') ? 'de' : 'en';
|
|
}
|
|
|
|
export function AboutClient({ locale }: { locale: string; translations: AboutTranslations }) {
|
|
const normalLocale = getNormalizedLocale(locale);
|
|
const baseMessages = messageMap[normalLocale];
|
|
|
|
const messages = {
|
|
home: {
|
|
about: baseMessages.home.about
|
|
}
|
|
};
|
|
|
|
return (
|
|
<NextIntlClientProvider locale={locale} messages={messages}>
|
|
<About />
|
|
</NextIntlClientProvider>
|
|
);
|
|
}
|
|
|
|
export function ProjectsClient({ locale }: { locale: string; translations: ProjectsTranslations }) {
|
|
const normalLocale = getNormalizedLocale(locale);
|
|
const baseMessages = messageMap[normalLocale];
|
|
|
|
const messages = {
|
|
home: {
|
|
projects: baseMessages.home.projects
|
|
}
|
|
};
|
|
|
|
return (
|
|
<NextIntlClientProvider locale={locale} messages={messages}>
|
|
<Projects />
|
|
</NextIntlClientProvider>
|
|
);
|
|
}
|
|
|
|
export function ContactClient({ locale }: { locale: string; translations: ContactTranslations }) {
|
|
const normalLocale = getNormalizedLocale(locale);
|
|
const baseMessages = messageMap[normalLocale];
|
|
|
|
const messages = {
|
|
home: {
|
|
contact: baseMessages.home.contact
|
|
}
|
|
};
|
|
|
|
return (
|
|
<NextIntlClientProvider locale={locale} messages={messages}>
|
|
<Contact />
|
|
</NextIntlClientProvider>
|
|
);
|
|
}
|
|
|
|
export function FooterClient({ locale }: { locale: string; translations: FooterTranslations }) {
|
|
const normalLocale = getNormalizedLocale(locale);
|
|
const baseMessages = messageMap[normalLocale];
|
|
|
|
const messages = {
|
|
footer: baseMessages.footer
|
|
};
|
|
|
|
return (
|
|
<NextIntlClientProvider locale={locale} messages={messages}>
|
|
<Footer />
|
|
</NextIntlClientProvider>
|
|
);
|
|
}
|