Article cross-reference linking

This commit is contained in:
Adrian Rumpold
2025-04-29 09:34:14 +02:00
parent 9597ccc3bd
commit 04f46e3893
3 changed files with 117 additions and 3 deletions

View File

@@ -25,6 +25,23 @@ function Panel({ language }: PanelProps) {
const articleElement = articleRef.current;
if (!articleElement) return;
// Replace cross-reference links with page navigation
const crossRefs = articleElement.querySelectorAll(
"a.cross-ref"
) as NodeListOf<HTMLAnchorElement>;
crossRefs.forEach((link) => {
const target = link.getAttribute("data-target");
const targetId = link.getAttribute("data-id");
if (target && targetId) {
if (target === "article") {
link.setAttribute("href", `../articles/${targetId}`);
}
} else {
console.warn("No target or ID found for link:", link);
}
});
const paragraphs = articleElement.querySelectorAll(".paragraph");
// Highlight the selected paragraph