notes/src/utils/remark.js

23 lines
886 B
JavaScript
Raw Normal View History

2026-06-05 14:31:12 -06:00
import { visit } from 'unist-util-visit';
export const ScriptureLinks = () => {
return async tree => {
visit(tree, node => {
if (node.type === 'link') {
if (node.url.startsWith(':scripture')) {
let passage;
if (node.url.indexOf('=') != -1) {
passage = node.url.substring(node.url.indexOf('=')+1).replace(/\+/, " ");
} else {
if (node.children.length != 0) {
passage = node.children[0].value;
}
}
const script = encodeURIComponent(passage.toLowerCase());
const url = `https://www.biblegateway.com/passage/?search=${script}&version=ESV`;
node.url = url;
}
}
});
};
};