import React, { useEffect } from 'react'; import { Head, Link, usePage, router } from '@inertiajs/react'; import { useTranslation } from 'react-i18next'; interface MarketingLayoutProps { children: React.ReactNode; title?: string; } const MarketingLayout: React.FC = ({ children, title }) => { const { t } = useTranslation('marketing'); const { url } = usePage(); const i18n = useTranslation(); useEffect(() => { const locale = url.startsWith('/en/') ? 'en' : 'de'; if (i18n.i18n.language !== locale) { i18n.i18n.changeLanguage(locale); } }, [url, i18n]); const { translations } = usePage().props as any; const marketing = translations?.marketing || {}; const getString = (key: string, fallback: string) => { const value = marketing[key]; return typeof value === 'string' ? value : fallback; }; const currentLocale = url.startsWith('/en/') ? 'en' : 'de'; const alternateLocale = currentLocale === 'de' ? 'en' : 'de'; const path = url.replace(/^\/(de|en)?/, ''); const canonicalUrl = `https://fotospiel.app/${currentLocale}${path}`; const alternateUrl = `https://fotospiel.app/${alternateLocale}${path}`; return ( <> {title || t('meta.title', getString('title', 'Fotospiel'))}
{children}
); }; export default MarketingLayout;