fix: ui fixes in transcript listing for books

This commit is contained in:
gosangam
2026-06-17 14:14:45 +05:30
parent fc2aef0c3d
commit bc1798b31b
2 changed files with 20 additions and 2 deletions
+14
View File
@@ -28,6 +28,20 @@ export function bookTitle(code: string): string {
return b ? b.title : "";
}
/**
* Extract the (starting) verse number from a reference, for ordering lectures
* within a chapter. The verse is the last dotted numeric component, and for a
* range we take the start: "BG 2.13" → 13, "SB 1.2.3" → 3, "SB 3.27.11–16" →
* 11, "CC Madhya-līlā 20.101" → 101, "ISO Mantra 4" → 4. References with no
* number (e.g. bare "NOD") sort last (stable → keep their incoming order).
*/
export function parseVerse(reference: string | null): number {
const m = (reference ?? "").trim().match(/(\d+(?:\.\d+)*)/);
if (!m) return Number.MAX_SAFE_INTEGER;
const parts = m[1].split(".");
return Number(parts[parts.length - 1]);
}
/** A section is a canto (SB) or līlā (CC); null for books without that level. */
export type ChapterSection = {
key: string;