/** * Data access layer for Śrī Brahma-saṁhitā (BS). * * Delegates to the generic book data layer (BFF API) for prose content, * and to lib/api.ts for verse lookups. * * BS has 62 texts (verses) plus intro segments. * Verses are stored with: book "bs", division null, chapter 5, verse = text number. */ import { getBookMeta, getIntroSegments, getIntroSegment, getChapter, getContent, getSidebarItems, type BookMeta, type IntroSegment, type Chapter, type SidebarItem, } from "@/lib/books"; import { getSingleVerse, type VerseRecord } from "@/lib/api"; const CODE = "bs"; // --------------------------------------------------------------------------- // Re-export types with book-specific names for backwards compatibility // --------------------------------------------------------------------------- export type BsMeta = BookMeta; export type BsIntroSegment = IntroSegment; export type BsChapter = Chapter; export type BsSidebarItem = SidebarItem; export type BsVerse = VerseRecord; // --------------------------------------------------------------------------- // Data accessors // --------------------------------------------------------------------------- export async function getBsMeta() { return getBookMeta(CODE); } export async function getBsIntroSegments() { return getIntroSegments(CODE); } export async function getBsIntroSegment(slug: string) { return getIntroSegment(CODE, slug); } export async function getBsVerse(slug: string): Promise { const num = parseInt(slug, 10); if (isNaN(num)) return null; return getSingleVerse(CODE, null, 5, num); } export async function getBsContent( slug: string, ): Promise { // Try as verse first (numeric slug) if (/^\d+$/.test(slug)) { const verse = await getBsVerse(slug); if (verse) return verse; } // Fall back to prose content (intro segments, etc.) return getContent(CODE, slug); } export async function getBsSidebarItems() { return getSidebarItems(CODE); }