import type { Metadata } from "next";
import HomePageServer from "../_ui/HomePageServer";
import { getLanguageAlternates, toAbsoluteUrl } from "@/lib/seo";

const localeMetadata: Record<string, { title: string; description: string }> = {
  de: {
    title: "Dennis Konkol – Webentwickler Osnabrück",
    description:
      "Dennis Konkol – Software Engineer & Webentwickler in Osnabrück. Webentwicklung, Fullstack-Apps, Docker, Next.js, Flutter. Projekte ansehen und Kontakt aufnehmen.",
  },
  en: {
    title: "Dennis Konkol – Web Developer Osnabrück",
    description:
      "Dennis Konkol – Software Engineer & Web Developer in Osnabrück, Germany. Web development, fullstack apps, Docker, Next.js, Flutter.",
  },
};

export async function generateMetadata({
  params,
}: {
  params: Promise<{ locale: string }>;
}): Promise<Metadata> {
  const { locale } = await params;
  const languages = getLanguageAlternates({ pathWithoutLocale: "" });
  const meta = localeMetadata[locale] ?? localeMetadata.en;
  return {
    title: meta.title,
    description: meta.description,
    alternates: {
      canonical: toAbsoluteUrl(`/${locale}`),
      languages,
    },
  };
}

export default async function Page({
  params,
}: {
  params: Promise<{ locale: string }>;
}) {
  const { locale } = await params;
  return <HomePageServer locale={locale} />;
}

