/** * Data access layer for The Nectar of Instruction (NoI). * * Delegates to the generic book data layer (BFF API) for prose intro segments, * and to lib/api.ts for verse (text) lookups. * * NoI has 11 texts (verses) plus intro segments. * Verses are stored with: book "noi", division null, chapter = text number, verse = 1. */ 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 = "noi"; // --------------------------------------------------------------------------- // Re-export types with book-specific names for backwards compatibility // --------------------------------------------------------------------------- export type NoiMeta = BookMeta; export type NoiIntroSegment = IntroSegment; export type NoiChapter = Chapter; export type NoiSidebarItem = SidebarItem; export type NoiVerse = VerseRecord; // --------------------------------------------------------------------------- // Book meta // --------------------------------------------------------------------------- export async function getNoiMeta() { return getBookMeta(CODE); } // --------------------------------------------------------------------------- // Intro segments // --------------------------------------------------------------------------- export async function getNoiIntroSegments() { return getIntroSegments(CODE); } export async function getNoiIntroSegment(slug: string) { return getIntroSegment(CODE, slug); } // --------------------------------------------------------------------------- // Verses (texts 1-11, from verses collection via BFF) // --------------------------------------------------------------------------- export async function getNoiVerse(slug: string): Promise { const num = parseInt(slug, 10); if (isNaN(num)) return null; return getSingleVerse(CODE, null, num, 1); } // --------------------------------------------------------------------------- // Unified content accessor // --------------------------------------------------------------------------- export async function getNoiContent( slug: string, ): Promise { // Try as verse first (numeric slug) if (/^\d+$/.test(slug)) { const verse = await getNoiVerse(slug); if (verse) return verse; } // Fall back to prose content (intro segments, etc.) return getContent(CODE, slug); } // --------------------------------------------------------------------------- // Sidebar navigation // --------------------------------------------------------------------------- export async function getNoiSidebarItems() { return getSidebarItems(CODE); }