Reftagger theme component

I made some headway with this using ChatGPT and have working reftaggers for both using Logos RefTagger and Blue Letter Bible.

If these could be bundled into a theme component for community use that is great if not the theme component is simply to make. You just need to take the code for whichever you prefer and put in the JS tab of a new theme component. You need to remove the default code is in the JS tab from Discourse.

If anyone has feedback how to improve that is welcome. My skills only go as far as guiding the LLM.

using Logos RefTagger:

import { apiInitializer } from “discourse/lib/api”;
import loadScript from “discourse/lib/load-script”;

export default apiInitializer(“0.1”, (api) => {
// 1. Define RefTagger settings on window BEFORE loading the script
window.refTagger = {
settings: {
bibleVersion: “ESV”, // e.g. default Bible version
tagChapters: true, // tag chapter references as well
convertHyperlinks: false, // don’t retag existing links
roundCorners: true,
socialSharing: ,
}
};

// 2. Hook into Discourse post rendering:
api.decorateCooked((element) => {
// Load the external RefTagger script (if not already loaded)
loadScript(“https://api.reftagger.com/v2/RefTagger.js”).then(() => {
// Run the tagging on the new content element
window.refTagger.tag(element);
});
});
});

using BLB ScriptTagger:

import { apiInitializer } from “discourse/lib/api”;
import loadScript from “discourse/lib/load-script”;

export default apiInitializer(“0.1”, (api) => {
// Optionally set BLB ScriptTagger settings before loading (defaults shown)
window.BLB ||= {}; // ensure global BLB object exists
window.BLB.Tagger ||= {};
window.BLB.Tagger.Translation = “NKJV”; // default translation version
window.BLB.Tagger.HyperLinks = “all”; // tag even already-linked refs
window.BLB.Tagger.TargetNewWindow = true; // links open in new tab
// … (other settings like DarkTheme, etc., as needed)

api.decorateCooked((elem) => {
loadScript(“https://www.blueletterbible.org/assets/scripts/blbToolTip/BLB_ScriptTagger-min.js”)
.then(() => {
if (window.BLB && window.BLB.Tagger) {
window.BLB.Tagger.pageInit(); // re-scan new content for verses:contentReference[oaicite:6]{index=6}
}
});
});
});