Consolidate the three duplicate Bible-book lookup tables into one shared registry
Publish Container / docker (push) Successful in 14m9s

src/App.tsx (Scripture Index book map) and server/routes/bible-passage.js
(BSB/bolls.life passage fetch) each hand-maintained their own independent
66-book list with a different key format (3-letter USFM id vs bolls.life's
numeric id), so a future alias/rename fix in one would silently not apply to
the other.

Add shared/bible-books.js as the single canonical list (name + aliases +
USFM id, in canonical order); the server derives its numeric bolls.life ids
from the array position instead of hand-maintaining a second table. Requires
allowJs + including shared/ in tsconfig.app.json so the client can import the
plain-JS module alongside its TypeScript sources.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Yvx4rPVy2HWe7ubuk3X3J
This commit is contained in:
nmemmertandClaude Sonnet 5 committed 2026-09-07 09:49:52 -04:00
1 parent c158fb6317
commit 335a9cbe31
4 files changed
+107 -86

No files matched your search

+14 -16
View File
@@ -1,21 +1,19 @@
import { BIBLE_BOOKS } from '../../shared/bible-books.js'
const passageCache = new Map()
const BOLLS_BOOK_MAP = {
genesis: 1, exodus: 2, leviticus: 3, numbers: 4, deuteronomy: 5,
joshua: 6, judges: 7, ruth: 8, '1samuel': 9, '2samuel': 10,
'1kings': 11, '2kings': 12, '1chronicles': 13, '2chronicles': 14,
ezra: 15, nehemiah: 16, esther: 17, job: 18, psalms: 19, proverbs: 20,
ecclesiastes: 21, songofsolomon: 22, isaiah: 23, jeremiah: 24,
lamentations: 25, ezekiel: 26, daniel: 27, hosea: 28, joel: 29,
amos: 30, obadiah: 31, jonah: 32, micah: 33, nahum: 34, habakkuk: 35,
zephaniah: 36, haggai: 37, zechariah: 38, malachi: 39,
matthew: 40, mark: 41, luke: 42, john: 43, acts: 44,
romans: 45, '1corinthians': 46, '2corinthians': 47, galatians: 48,
ephesians: 49, philippians: 50, colossians: 51, '1thessalonians': 52,
'2thessalonians': 53, '1timothy': 54, '2timothy': 55, titus: 56,
philemon: 57, hebrews: 58, james: 59, '1peter': 60, '2peter': 61,
'1john': 62, '2john': 63, '3john': 64, jude: 65, revelation: 66,
}
// Keyed by lowercase, whitespace-stripped book name/alias (matching the format
// the admin's "Bible Book" field and the /api/bible-passage `book` query param
// both use), mapped to bolls.life's numeric book id (canonical order, 1-66).
// Derived from the shared BIBLE_BOOKS list so it can't drift from the client's
// Scripture Index book map (src/App.tsx's SI_BOOK_MAP).
const BOLLS_BOOK_MAP = {}
BIBLE_BOOKS.forEach((b, index) => {
const bookNum = index + 1
for (const key of [b.name.toLowerCase(), ...(b.aliases ?? [])]) {
BOLLS_BOOK_MAP[key.replace(/\s+/g, '')] = bookNum
}
})
function parseReference(reference) {
const stripped = reference.replace(/^[a-z]+/i, '')