@@ -29,13 +29,17 @@ async function loadBookData(bookFile) {
2929}
3030
3131async function loadBook ( bookFile ) {
32- bookData = await loadBookData ( bookFile ) ;
33- currentBook = Object . keys ( bookData ) [ 0 ] ;
34- currentChapter = Object . keys ( bookData [ currentBook ] ) [ 0 ] ;
35-
36- document . getElementById ( 'navigation' ) . style . display = 'flex' ;
37- updateChapterNavigation ( ) ;
38- loadChapter ( currentChapter ) ;
32+ try {
33+ bookData = await loadBookData ( bookFile ) ;
34+ currentBook = Object . keys ( bookData ) [ 0 ] ;
35+ currentChapter = Object . keys ( bookData [ currentBook ] ) [ 0 ] ;
36+
37+ document . getElementById ( 'navigation' ) . style . display = 'flex' ;
38+ updateChapterNavigation ( ) ;
39+ loadChapter ( currentChapter ) ;
40+ } catch ( error ) {
41+ console . error ( "Failed to load book:" , error ) ;
42+ }
3943}
4044
4145function updateChapterNavigation ( ) {
@@ -102,5 +106,31 @@ window.addEventListener('resize', () => {
102106 }
103107} ) ;
104108
105- // Initialize the app
106- initBooks ( ) ; // Critical missing line added
109+ // Load Genesis by default
110+ window . addEventListener ( 'DOMContentLoaded' , async ( ) => {
111+ // Find Genesis in book manifest
112+ const genesisBook = bookManifest . find ( b => b . name === "Genesis" ) ;
113+
114+ if ( genesisBook ) {
115+ await loadBook ( genesisBook . file ) ;
116+
117+ // Close mobile sidebar after loading
118+ if ( window . innerWidth < 768 ) {
119+ document . getElementById ( 'sidebar' ) . style . left = '-100%' ;
120+ }
121+ }
122+ } ) ;
123+
124+ // Initialize books and load Genesis
125+ function initApp ( ) {
126+ initBooks ( ) ;
127+
128+ // Load Genesis after slight delay to ensure DOM is ready
129+ setTimeout ( async ( ) => {
130+ const genesis = bookManifest . find ( b => b . name === "Genesis" ) ;
131+ if ( genesis ) await loadBook ( genesis . file ) ;
132+ } , 100 ) ;
133+ }
134+
135+ // Start the app
136+ initApp ( ) ;
0 commit comments