import fs from "fs"; import path from "path"; import Link from "next/link"; import { notFound } from "next/navigation"; import { ExtractedVerseCount } from "../../extracted-verse-count"; type ChapterInfo = { number: number; title: string; totalVerses: number; }; type CantoInfo = { number: number; title: string; totalChapters: number; chapters: ChapterInfo[]; }; type Intro = { book: string; title: string; author: string; totalCantos: number; cantos: CantoInfo[]; }; function getIntro(): Intro { const introPath = path.join(process.cwd(), "app/lib/books/sb/intro.json"); return JSON.parse(fs.readFileSync(introPath, "utf-8")); } export default async function CantoPage({ params, }: { params: Promise<{ canto: string }>; }) { const { canto } = await params; const cantoNum = parseInt(canto); const intro = getIntro(); const cantoInfo = intro.cantos.find((c) => c.number === cantoNum); if (!cantoInfo) notFound(); const totalVerses = cantoInfo.chapters.reduce( (sum, ch) => sum + ch.totalVerses, 0, ); return (
← Śrīmad-Bhāgavatam

Canto {cantoInfo.number}: {cantoInfo.title}

{cantoInfo.totalChapters} chapters ·{" "}

); }