// TODO: move to common location const parseHTML = (html: string, fragment = false) => { const template = document.createElement("template"); template.innerHTML = html; const node = template.content.cloneNode(true); if (fragment) return node; return node.childNodes.length > 1 ? node.childNodes : node.childNodes[0]; }; // TODO: See if there's a way to inject this without client-side js const metaString = ` `; export default function addOpenGraphMeta() { const currentTitle = document.querySelector("title")!; currentTitle.textContent = currentTitle.textContent === "Trilium Rocks" ? "Trilium Rocks - Home" : `Trilium Rocks - ${currentTitle.textContent}`; const nodes = parseHTML(metaString.replaceAll("{{title}}", currentTitle.textContent)) as NodeListOf; for (const node of nodes) { document.head.append(node); } }