fix: ui fixes in transcript listing for books
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user