mirror of
https://github.com/bitbaum/vitareba.git
synced 2026-12-05 06:28:18 +01:00
feat(seo): localized title, description and OG metadata per locale
Generates locale-specific <title>, <meta description>, openGraph and twitter tags from new meta.tagline + meta.description translation keys in de/en/fr/it. German visitors (default locale, primary market) now get German meta tags instead of the hardcoded English fallback in the root layout. OG locale is mapped to Swiss variants (de_CH, fr_CH, it_CH) where applicable. Brand name and city stay in COMPANY config (SSOT). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
5 files changed
+42
-5
No files matched your search
+26
-5
@@ -1,11 +1,19 @@
|
||||
import type { Metadata } from "next";
|
||||
import { NextIntlClientProvider } from "next-intl";
|
||||
import { getMessages, setRequestLocale } from "next-intl/server";
|
||||
import { getMessages, getTranslations, setRequestLocale } from "next-intl/server";
|
||||
import { notFound } from "next/navigation";
|
||||
import { routing } from "@/i18n/routing";
|
||||
import { SITE_URL } from "@/lib/config/company";
|
||||
import { COMPANY, SITE_URL } from "@/lib/config/company";
|
||||
import { AssessmentOverlay } from "@/components/sections/AssessmentOverlay";
|
||||
|
||||
// Maps next-intl locale codes to OpenGraph locale identifiers (Swiss variants where applicable).
|
||||
const OG_LOCALE: Record<string, string> = {
|
||||
de: "de_CH",
|
||||
en: "en_US",
|
||||
fr: "fr_CH",
|
||||
it: "it_CH",
|
||||
};
|
||||
|
||||
type Props = {
|
||||
children: React.ReactNode;
|
||||
params: Promise<{ locale: string }>;
|
||||
@@ -17,6 +25,11 @@ export function generateStaticParams() {
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
const t = await getTranslations({ locale, namespace: "meta" });
|
||||
|
||||
const title = `${COMPANY.shortName} · ${t("tagline")} · ${COMPANY.address.city}`;
|
||||
const description = t("description");
|
||||
const url = `${SITE_URL}/${locale}`;
|
||||
|
||||
// Build hreflang map for all supported locales
|
||||
const languages = Object.fromEntries(
|
||||
@@ -24,10 +37,18 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
);
|
||||
|
||||
return {
|
||||
alternates: {
|
||||
canonical: `${SITE_URL}/${locale}`,
|
||||
languages,
|
||||
title,
|
||||
description,
|
||||
alternates: { canonical: url, languages },
|
||||
openGraph: {
|
||||
title,
|
||||
description,
|
||||
url,
|
||||
siteName: COMPANY.name,
|
||||
type: "website",
|
||||
locale: OG_LOCALE[locale] ?? OG_LOCALE.de,
|
||||
},
|
||||
twitter: { card: "summary_large_image", title, description },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"meta": {
|
||||
"tagline": "Metabolische Psychiatrie & Systemische Longevity",
|
||||
"description": "Klinik in Zürich für metabolische Psychiatrie und systemische Longevity. ADHD-Diagnostik, biologieorientierte Behandlung und personalisierte Optimierung für Hochleister."
|
||||
},
|
||||
"nav": {
|
||||
"programmes": "Programme",
|
||||
"approach": "Ansatz",
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"meta": {
|
||||
"tagline": "Metabolic Psychiatry & Systemic Longevity",
|
||||
"description": "Zürich clinic for metabolic psychiatry and systemic longevity. ADHD diagnostics, biology-led treatment and personalised optimisation for high performers."
|
||||
},
|
||||
"nav": {
|
||||
"programmes": "Programmes",
|
||||
"approach": "Approach",
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"meta": {
|
||||
"tagline": "Psychiatrie Métabolique & Longévité Systémique",
|
||||
"description": "Clinique zurichoise de psychiatrie métabolique et longévité systémique. Diagnostic ADHD, traitement biologique et optimisation personnalisée pour les hauts performeurs."
|
||||
},
|
||||
"nav": {
|
||||
"programmes": "Programmes",
|
||||
"approach": "Approche",
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"meta": {
|
||||
"tagline": "Psichiatria Metabolica & Longevità Sistemica",
|
||||
"description": "Clinica zurighese di psichiatria metabolica e longevità sistemica. Diagnostica ADHD, trattamento biologico e ottimizzazione personalizzata per alte prestazioni."
|
||||
},
|
||||
"nav": {
|
||||
"programmes": "Programmi",
|
||||
"approach": "Approccio",
|
||||
|
||||
Reference in new issue
Block a user