{verse.devanagari}
{verse.transliteration}
Synonyms
{verse.synonyms.map((s, i) => ( {s.word} —{s.meanings.join(", ")} {i < verse.synonyms.length - 1 ? "; " : "."} ))}
import fs from "fs"; import path from "path"; import Link from "next/link"; import { notFound } from "next/navigation"; import { VerseIndex } from "./verse-index"; type Synonym = { word: string; meanings: string[]; }; type Verse = { book_title: string; chapter: number; verse: number; verse_end?: number; reference: string; devanagari: string; transliteration: string; synonyms: Synonym[]; translation: string; purport: string[]; }; function getChapterVerses(chapter: string): Verse[] { const dir = path.join( process.cwd(), "app/lib/books/bg/chapters", chapter.padStart(2, "0"), "verses", ); if (!fs.existsSync(dir)) return []; return fs .readdirSync(dir) .filter((f) => f.endsWith(".json")) .sort((a, b) => { const na = parseInt(a); const nb = parseInt(b); return na - nb; }) .map((f) => JSON.parse(fs.readFileSync(path.join(dir, f), "utf-8"))); } function getChapterTitle(chapter: string): string | null { const introPath = path.join(process.cwd(), "app/lib/books/bg/intro.json"); const intro = JSON.parse(fs.readFileSync(introPath, "utf-8")); const ch = intro.chapters.find( (c: { number: number }) => c.number === parseInt(chapter), ); return ch?.title || null; } export default async function ChapterPage({ params, }: { params: Promise<{ chapter: string }>; }) { const { chapter } = await params; const title = getChapterTitle(chapter); if (!title) notFound(); const verses = getChapterVerses(chapter); if (verses.length === 0) notFound(); const verseList = verses.map((v) => ({ verse: v.verse, verse_end: v.verse_end, reference: v.reference, })); return (
{verse.devanagari}
{verse.transliteration}
{verse.synonyms.map((s, i) => ( {s.word} —{s.meanings.join(", ")} {i < verse.synonyms.length - 1 ? "; " : "."} ))}