import type { Metadata } from "next";
import { notFound } from "next/navigation";
import EntryDetailClient from "./EntryDetail";
import { getEntryById } from "@/server/repo";

export const revalidate = 3600;

export async function generateMetadata({ params }: { params: Promise<{ id: string }> }): Promise<Metadata> {
  const { id } = await params;
  const data = await getEntryById(Number(id));
  if (!data) return { title: "Entry Not Found | ZXDB" };
  return { title: `${data.title} | ZXDB Entry` };
}

export default async function Page({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const data = await getEntryById(Number(id));
  if (!data) notFound();
  return <EntryDetailClient data={data} />;
}
