import { notFound } from "next/navigation"; import { prisma } from "@/lib/db"; import { ChapterList } from "@/components/ChapterList"; import type { Metadata } from "next"; type Props = { params: Promise<{ slug: string }>; }; export async function generateMetadata({ params }: Props): Promise { const { slug } = await params; const manga = await prisma.manga.findUnique({ where: { slug } }); if (!manga) return { title: "Not Found" }; return { title: manga.title, description: manga.description, openGraph: { title: manga.title, description: manga.description, images: [manga.coverUrl], }, }; } export default async function MangaDetailPage({ params }: Props) { const { slug } = await params; const manga = await prisma.manga.findUnique({ where: { slug }, include: { chapters: { orderBy: { number: "asc" }, }, }, }); if (!manga) notFound(); return (
{/* Hero section */}
{manga.title}

{manga.title}

{manga.genre} {manga.status} {manga.chapters.length} chapter {manga.chapters.length !== 1 ? "s" : ""}

{manga.description}

{/* Continue reading button */} {manga.chapters.length > 0 && ( Start Reading — Ch. {manga.chapters[0].number} )} {/* Chapters */}

Chapters

); }