diff --git a/src/pages/notes/[...id].astro b/src/pages/notes/[...id].astro index 6c12f1e..acf3394 100644 --- a/src/pages/notes/[...id].astro +++ b/src/pages/notes/[...id].astro @@ -73,7 +73,7 @@ const meta = `{ - + Open on Bible Gateway diff --git a/src/styles/global.css b/src/styles/global.css index 9084f13..ffecf42 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -139,9 +139,12 @@ dialog.scripture { p.poem-1, p.poem-2 { @apply mb-0; } + p.poem-1 { + @apply pl-6; + } p.poem-2 { - @apply mt-0; - } + @apply mt-0 pl-14; + } button[data-close] { @apply absolute top-0 right-0 pr-2 pb-2 pt-2 text-sm text-gray-500 cursor-pointer hover:text-red-900; span { @@ -151,7 +154,7 @@ dialog.scripture { nav { @apply mt-8; a { - @apply absolute bottom-0 right-0 text-sm text-blue-400 pr-4 pb-4; + @apply bottom-0 right-0 text-sm text-blue-400 pr-4 pb-4; } } } diff --git a/src/utils/modal.js b/src/utils/modal.js index dfe5d1a..356e422 100644 --- a/src/utils/modal.js +++ b/src/utils/modal.js @@ -13,13 +13,18 @@ function parseRef(ref) { const book = m[1]; const chapter = m[5]; - const verses = m[6]; + const verses = m[6]?.replaceAll(/–/g, '-'); + + console.log(`parseRef: ${book}, ${chapter}, ${verses}`); + console.log(books); if (book === undefined) { return {}; } - let refdata = {}; + let refdata = { + ref: ref + }; if (book in books) { refdata.book = book; } else if (book in _map) { @@ -36,13 +41,13 @@ function parseRef(ref) { if (verses !== undefined) { if (verses.indexOf('-') < 0) { refdata['verses'] = { - start: verses, - end: verses + start: parseInt(verses), + end: parseInt(verses) }; } else { refdata['verses'] = { - start: verses.substring(0, verses.indexOf('-')), - end: verses.substring(verses.indexOf('-')+1) + start: parseInt(verses.substring(0, verses.indexOf('-'))), + end: parseInt(verses.substring(verses.indexOf('-')+1)) }; } } @@ -52,15 +57,9 @@ function parseRef(ref) { if (refdata.verses.start < 1) { refdata.verses.start = 1; } - if (refdata.verses.start > refdata.meta.stop) { - refdata.verses.start = refdata.meta.stop; - } if (refdata.verses.end < 1) { refdata.verses.end = 1; } - if (refdata.verses.end > refdata.meta.stop) { - refdata.verses.end = refdata.meta.stop; - } if (refdata.verses.start > refdata.verses.end) { refdata.verses.end = refdata.verses.start; } @@ -69,18 +68,21 @@ function parseRef(ref) { return refdata; } -function render(dialog, response) { +function render(dialog, response, refs) { const content = response?.chapter?.content; - const refs = parseRef('gen+1:4'); let inSpan = false; if (dialog === null || dialog === undefined) { return; } + console.log('render refs:', refs); + const section = document.createElement('section'); let para = document.createElement('p'); + dialog.querySelector('a.bg').href = `https://www.biblegateway.com/passage/?search=${refs.ref}&version=ESV` + for (const c of content) { if (c.type === 'heading') { continue; @@ -137,9 +139,9 @@ function render(dialog, response) { } break; default: - console.log('unhandled type:', c.type); + console.error('unhandled type:', c.type); } - console.log(c); + //console.log(c); } section.insertAdjacentElement('beforeend', para); dialog?.querySelector('article').insertAdjacentElement('beforeend', section); @@ -152,32 +154,36 @@ export const bindModals = () => { elems.forEach((e) => { e.addEventListener('click', (evt) => { const scripture = e.attributes.getNamedItem('data-scripture'); + const refs = parseRef(scripture.value); evt.preventDefault(); - console.log(scripture); - console.log(parseRef(scripture.value)); + console.log('scripture:', scripture); + console.log('refs:', refs); + const uri = `https://bible.helloao.org/api/BSB/${refs.book.toUpperCase()}/${refs.chapter}.json`; dialog[0]?.showModal(); dialog[0]?.setAttribute('data-scripture', scripture); dialog[0]?.classList.remove("hidden"); //document.body.classList.add("overflow-hidden"); - fetch('https://aries.destrealm.org/bshelton/gen1.json') + fetch(uri) .then((response) => { console.log(response.ok); return response.json(); }) .then((response) => { - render(dialog[0], response); + render(dialog[0], response, refs); }); }); }); dialog[0]?.addEventListener('click', (evt) => { - evt.target === dialog[0] && dialog[0]?.close(); - dialog[0]?.querySelector('article')?.replaceChildren(); - + if (evt.target === dialog[0]) { + dialog[0]?.close(); + dialog[0]?.querySelector('article')?.replaceChildren(); + } }); dialog[0]?.querySelector('button[data-close]')?.addEventListener('click', (evt) => { evt.preventDefault(); dialog[0]?.close(); + dialog[0]?.classList.add('hidden'); dialog[0]?.querySelector('article')?.replaceChildren(); }); }; @@ -240,7 +246,7 @@ const books = { "aliases": ["jo"], }, "psa": {"title": "Psalms", "start": 1, "stop": 150, "count": 150, - "aliases": ["ps", "pss"], + "aliases": ["ps", "psalm", "pss"], }, "pro": {"title": "Proverbs", "start": 1, "stop": 31, "count": 31, "aliases": ["pr", "prov"],