import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { HomePage } from "@/components/home-page";
import { getPortfolioContent, isLanguage, languages, type Language } from "@/data/portfolio";

export function generateStaticParams() {
  return languages.map((lang) => ({ lang }));
}

export function generateMetadata({ params }: { params: { lang: string } }): Metadata {
  if (!isLanguage(params.lang)) {
    return {};
  }

  const language = params.lang as Language;
  const t = getPortfolioContent(language);

  return {
    title: t.meta.title,
    description: t.meta.description,
    alternates: {
      canonical: `/${language}`,
      languages: {
        en: "/en",
        ar: "/ar",
      },
    },
  };
}

export default function LocalizedHomePage({ params }: { params: { lang: string } }) {
  if (!isLanguage(params.lang)) {
    notFound();
  }

  return <HomePage language={params.lang as Language} />;
}
