function htmlToElement(html) { const template = document.createElement('template') html = html.trim() template.innerHTML = html return template.content.firstChild } function initPopover(baseURL, useContextualBacklinks) { const basePath = baseURL.replace(window.location.origin, "") document.addEventListener("DOMContentLoaded", () => { fetchData.then(({ content }) => { const links = [...document.getElementsByClassName("internal-link")] links .filter(li => li.dataset.src || (li.dataset.idx && useContextualBacklinks)) .forEach(li => { if (li.dataset.ctx) { console.log(li.dataset.ctx) const linkDest = content[li.dataset.src] const popoverElement = `
${highlight(removeMarkdown(linkDest.content), li.dataset.ctx)}...
${removeMarkdown(linkDest.content).split(" ", 20).join(" ")}...