diff --git a/src/utils/rehype.js b/src/utils/rehype.js index c6ffabe..c61c704 100644 --- a/src/utils/rehype.js +++ b/src/utils/rehype.js @@ -7,6 +7,7 @@ export const ScriptureLinks = () => { visit(tree, 'element', (node) => { let passage = ''; let isQuote = false; + let isCite = false; const url = node.properties.href; if (node.tagName !== 'a') { return; @@ -19,6 +20,8 @@ export const ScriptureLinks = () => { for (const arg of args) { if (arg === 'quote') { isQuote = true; + } else if (arg === 'cite') { + isCite = true; } else { passage = arg; } @@ -37,11 +40,21 @@ export const ScriptureLinks = () => { passage = passage.replace(/ /, '+'); passage = passage.replace(/\:/, '%3A'); - node.properties.href = `https://www.biblegateway.com/passage/?search=${passage}&version=ESV`; + + if (passage !== '') { + node.properties.href = `https://www.biblegateway.com/passage/?search=${passage}&version=ESV`; + } node.properties.class = 'scripture'; if (isQuote) { - node.properties.class = 'scripture quote'; + node.properties.class += ' quote'; + } + if (isCite) { + if (passage === '') { + node.properties.href = null; + node.properties.title = 'Scriptural citation or fragmentary citation'; + } + node.properties.class += ' cite'; } if (match) {