fix: bg verses now show range of verses

This commit is contained in:
gosangam
2026-04-14 14:46:16 +05:30
parent 82b6685c97
commit 83fec22f53
37 changed files with 151 additions and 86 deletions
+7 -10
View File
@@ -10,8 +10,10 @@ type Synonym = {
};
type Verse = {
book_title: string;
chapter: number;
verse: number;
verse_end?: number;
reference: string;
devanagari: string;
transliteration: string;
@@ -25,7 +27,7 @@ function getChapterVerses(chapter: string): Verse[] {
process.cwd(),
"app/lib/books/bg/chapters",
chapter.padStart(2, "0"),
"verses"
"verses",
);
if (!fs.existsSync(dir)) return [];
@@ -41,13 +43,10 @@ function getChapterVerses(chapter: string): Verse[] {
}
function getChapterTitle(chapter: string): string | null {
const introPath = path.join(
process.cwd(),
"app/lib/books/bg/intro.json"
);
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)
(c: { number: number }) => c.number === parseInt(chapter),
);
return ch?.title || null;
}
@@ -66,6 +65,7 @@ export default async function ChapterPage({
const verseList = verses.map((v) => ({
verse: v.verse,
verse_end: v.verse_end,
reference: v.reference,
}));
@@ -158,10 +158,7 @@ export default async function ChapterPage({
</h3>
<div className="text-sm text-zinc-700 dark:text-zinc-300 leading-relaxed space-y-3">
{verse.purport.map((p, i) => (
<p
key={i}
dangerouslySetInnerHTML={{ __html: p }}
/>
<p key={i} dangerouslySetInnerHTML={{ __html: p }} />
))}
</div>
</div>