import type { Metadata } from "next"; import Link from "next/link"; import { PageHeader } from "@/components/layout/page-header"; import { notFound } from "next/navigation"; import { Card, CardContent } from "@/components/ui/card"; import { FindInPage } from "@/components/layout/find-in-page"; import { ExtractedVerseCount } from "../../extracted-verse-count"; import { getBookMeta, getProseChapter } from "@/lib/api"; import { buildOgMeta } from "@/lib/og"; import { BOOK_NAMES, CC_LILAS } from "@/lib/constants"; export async function generateMetadata({ params, }: { params: Promise<{ lila: string }>; }): Promise { const { lila } = await params; const bookTitle = BOOK_NAMES["cc"] || "Śrī Caitanya-caritāmṛta"; // A non-līlā segment (front-flap, preface, introduction) is front matter. if (!CC_LILAS[lila]) { const segment = await getProseChapter("cc", 0, lila); if (segment) { return buildOgMeta({ title: bookTitle, detail: segment.title }); } } return buildOgMeta({ title: bookTitle, detail: CC_LILAS[lila] || lila }); } type ChapterInfo = { number: number; title: string; totalVerses: number; }; type LilaInfo = { key: string; name: string; totalChapters: number; totalVerses: number; chapters: ChapterInfo[]; }; export default async function LilaPage({ params, }: { params: Promise<{ lila: string }>; }) { const { lila } = await params; const meta = await getBookMeta("cc"); if (!meta) notFound(); const lilas = meta.lilas as LilaInfo[]; const lilaInfo = lilas.find((l) => l.key === lila); // Front matter — the param is not a līlā key, so resolve it as a prose // intro-segment (front-flap, preface, introduction). if (!lilaInfo) { const segment = await getProseChapter("cc", 0, lila); if (!segment) notFound(); return (
← Śrī Caitanya-caritāmṛta

{segment.title}

{segment.paragraphs.map((paragraph, i) => (
))}
); } const totalVerses = lilaInfo.chapters.reduce( (sum, ch) => sum + ch.totalVerses, 0, ); return (
← Śrī Caitanya-caritāmṛta

{lilaInfo.name}

{lilaInfo.totalChapters} chapters ·{" "}

    {lilaInfo.chapters.map((ch) => (
  • Chapter {ch.number}

    {ch.title}

  • ))}
); }