import Link from "next/link"; import { PageHeader } from "@/components/page-header"; import { notFound } from "next/navigation"; import { getBookMeta, getChapterVerses, getChapterVerseIndex } from "@/lib/api"; import { ChapterViewer } from "@/app/books/chapter-viewer"; type BgMeta = { book: string; title: string; author: string; totalChapters: number; chapters: { number: number; title: string; totalVerses: number }[]; }; export default async function ChapterPage({ params, }: { params: Promise<{ chapter: string }>; }) { const { chapter } = await params; const PAGE_SIZE = 20; const meta = await getBookMeta("bg"); if (!meta) notFound(); const bgMeta = meta as unknown as BgMeta; const chapterInfo = bgMeta.chapters?.find( (c) => c.number === parseInt(chapter), ); if (!chapterInfo?.title) notFound(); const title: string = chapterInfo.title; const [verseIndex, firstPage] = await Promise.all([ getChapterVerseIndex("bg", null, parseInt(chapter)), getChapterVerses("bg", null, parseInt(chapter), 1, PAGE_SIZE), ]); if (verseIndex.length === 0) notFound(); return (