import { isLocale, type Locale, publicPath } from "@/i18n/routes";
import { getDict } from "@/i18n/dictionaries";
import { getLegal } from "@/content/legal";
import { buildMetadata } from "@/lib/metadata";

export async function generateMetadata({
  params,
}: {
  params: Promise<{ lang: string }>;
}) {
  const { lang } = await params;
  const locale: Locale = isLocale(lang) ? lang : "de";
  return buildMetadata(locale, getDict(locale).legal.title, "Impressum", { path: publicPath(locale, "legal") });
}

export default async function LegalPage({
  params,
}: {
  params: Promise<{ lang: string }>;
}) {
  const { lang } = await params;
  const locale: Locale = isLocale(lang) ? lang : "de";
  const dict = getDict(locale);
  const legal = getLegal(locale);
  return (
    <article className="ascii-box mx-auto max-w-3xl space-y-4">
      <div className="section-heading">
        <span className="section-heading__label">~/legal</span>
        <h1 className="section-heading__title">{dict.legal.title}</h1>
      </div>
      <p>
        <strong>{legal.name}</strong>
        <br />
        {legal.city}
      </p>
      <p>{legal.contactHint}</p>
    </article>
  );
}
