From 081adb02be305ceab7408792971daf5b88adc566 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Mon, 26 Jan 2026 23:45:37 +0100 Subject: [PATCH] fix --- app/[locale]/page.tsx | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index d14b9020..b1b46300 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -11,6 +11,8 @@ import GallerySection from '@/components/home/GallerySection'; import VideoSection from '@/components/home/VideoSection'; import CTA from '@/components/home/CTA'; import Reveal from '@/components/Reveal'; +import { getTranslations } from 'next-intl/server'; +import { Metadata } from 'next'; export default function HomePage({ params: { locale } }: { params: { locale: string } }) { return ( @@ -34,3 +36,45 @@ export default function HomePage({ params: { locale } }: { params: { locale: str ); } + +export async function generateMetadata({ params: { locale } }: { params: { locale: string } }): Promise { + // Use translations for meta where available (namespace: Home.meta) + // Fallback to a sensible default if translation keys are missing. + let t; + try { + t = await getTranslations({ locale, namespace: 'Home.meta' }); + } catch (err) { + // If translations for Home.meta are not present, try generic Home namespace + try { + t = await getTranslations({ locale, namespace: 'Home' }); + } catch (e) { + t = (key: string) => ''; + } + } + + const title = t('title') || 'KLZ Cables'; + const description = t('description') || t('subtitle') || ''; + + return { + title, + description, + alternates: { + canonical: `/${locale}`, + languages: { + 'de': '/de', + 'en': '/en', + 'x-default': '/en', + }, + }, + openGraph: { + title: `${title} | KLZ Cables`, + description, + url: `https://klz-cables.com/${locale}`, + }, + twitter: { + card: 'summary_large_image', + title: `${title} | KLZ Cables`, + description, + }, + }; +}