import { notFound } from "next/navigation";
import type { Metadata } from "next";
import { ARTISTS, getArtist } from "@/lib/mock-data";
import ArtistDetailContent from "@/components/artist/ArtistDetailContent";

interface ArtistPageProps {
  params: Promise<{ id: string }>;
}

export async function generateStaticParams() {
  return ARTISTS.map((a) => ({ id: a.id }));
}

export async function generateMetadata({
  params,
}: ArtistPageProps): Promise<Metadata> {
  const { id } = await params;
  const artist = getArtist(id);
  if (!artist) return { title: "艺人不存在 · CYBER STAR" };

  return {
    title: `${artist.name} · ${artist.enName} · CYBER STAR`,
    description: artist.bio.slice(0, 120),
  };
}

export default async function ArtistPage({ params }: ArtistPageProps) {
  const { id } = await params;
  const artist = getArtist(id);
  if (!artist) notFound();
  return <ArtistDetailContent artist={artist} allArtists={ARTISTS} />;
}
