All checks were successful
CI / update (push) Successful in 1m34s
- Extract Bible lookup logic into shared src/lib/server/bible.ts module - Add build script to pre-generate all 20 mystery verse lookups as static data, eliminating runtime API calls on rosary page load - Update Prayer.svelte to pass showLatin/urlLang as snippet parameters; all 14 prayer components now conditionally render only visible language elements instead of hiding via CSS - Extract 4 inline mystery selector SVGs into MysteryIcon.svelte component - Remove unused CSS selectors from angelus page
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
/**
|
|
* Pre-generates Bible verse data for all rosary mystery references.
|
|
* Run with: npx vite-node scripts/generate-mystery-verses.ts
|
|
*/
|
|
import { writeFileSync } from 'fs';
|
|
import { resolve } from 'path';
|
|
import { lookupReference } from '../src/lib/server/bible';
|
|
import { mysteryReferences } from '../src/lib/data/mysteryDescriptions';
|
|
import type { MysteryDescription, VerseData } from '../src/lib/data/mysteryDescriptions';
|
|
|
|
const tsvPath = resolve('static/allioli.tsv');
|
|
|
|
const mysteryDescriptions: Record<string, MysteryDescription[]> = {};
|
|
|
|
for (const [mysteryType, references] of Object.entries(mysteryReferences)) {
|
|
const descriptions: MysteryDescription[] = [];
|
|
|
|
for (const ref of references) {
|
|
const result = lookupReference(ref.reference, tsvPath);
|
|
|
|
let text = '';
|
|
let verseData: VerseData | null = null;
|
|
|
|
if (result && result.verses.length > 0) {
|
|
text = `«${result.verses.map((v) => v.text).join(' ')}»`;
|
|
verseData = {
|
|
book: result.book,
|
|
chapter: result.chapter,
|
|
verses: result.verses
|
|
};
|
|
} else {
|
|
console.warn(`No verses found for: ${ref.reference}`);
|
|
}
|
|
|
|
descriptions.push({
|
|
title: ref.title,
|
|
reference: ref.reference,
|
|
text,
|
|
verseData
|
|
});
|
|
}
|
|
|
|
mysteryDescriptions[mysteryType] = descriptions;
|
|
}
|
|
|
|
const output = `// Auto-generated by scripts/generate-mystery-verses.ts — do not edit manually
|
|
import type { MysteryDescription } from './mysteryDescriptions';
|
|
|
|
export const mysteryVerseData: Record<string, MysteryDescription[]> = ${JSON.stringify(mysteryDescriptions, null, '\t')};
|
|
`;
|
|
|
|
const outPath = resolve('src/lib/data/mysteryVerseData.ts');
|
|
writeFileSync(outPath, output, 'utf-8');
|
|
console.log(`Wrote mystery verse data to ${outPath}`);
|