diff --git a/pages/documentation/index.vue b/pages/documentation/index.vue index f2fce5e..cb9c900 100644 --- a/pages/documentation/index.vue +++ b/pages/documentation/index.vue @@ -39,8 +39,8 @@ renderer.heading = function (text, level, raw) { }; // Custom link renderer for internal .md links renderer.link = function (href, title, text) { - if (href && String(href).endsWith('.md')) { - const file = String(href).split('/').pop(); + if (href && String(href).endsWith(".md")) { + const file = String(href).split("/").pop(); // Use a special class for delegation return `${text}`; } @@ -71,9 +71,9 @@ onMounted(async () => { .replace(/\{\s*\[native code\]\s*\}/gi, "") .replace(/^\s*\[object.*?\]\s*$/gim, "") .trim(); - + let html = marked.parse(content); - + // Post-process HTML to remove any remaining object references html = html .replace(/\[object Object\]/g, "") @@ -140,8 +140,11 @@ onUnmounted(() => { // Scrollspy for TOC function handleScrollSpy() { - const headings = Array.from(document.querySelectorAll('.prose h2, .prose h3')); - const scrollY = window.scrollY || document.querySelector('.main-content')?.scrollTop || 0; + const headings = Array.from( + document.querySelectorAll(".prose h2, .prose h3") + ); + const scrollY = + window.scrollY || document.querySelector(".main-content")?.scrollTop || 0; let current = null; for (const heading of headings) { const rect = heading.getBoundingClientRect(); @@ -153,30 +156,34 @@ function handleScrollSpy() { } onMounted(() => { - document.querySelector('.main-content')?.addEventListener('scroll', handleScrollSpy); - window.addEventListener('scroll', handleScrollSpy); + document + .querySelector(".main-content") + ?.addEventListener("scroll", handleScrollSpy); + window.addEventListener("scroll", handleScrollSpy); }); onUnmounted(() => { - document.querySelector('.main-content')?.removeEventListener('scroll', handleScrollSpy); - window.removeEventListener('scroll', handleScrollSpy); + document + .querySelector(".main-content") + ?.removeEventListener("scroll", handleScrollSpy); + window.removeEventListener("scroll", handleScrollSpy); }); // Event delegation for .doc-link clicks onMounted(() => { const handler = (e) => { - const target = e.target.closest('.doc-link'); + const target = e.target.closest(".doc-link"); if (target && target.dataset.doc) { e.preventDefault(); e.stopPropagation(); selectDoc(target.dataset.doc); } }; - document.addEventListener('click', handler); + document.addEventListener("click", handler); window.__docLinkHandler = handler; }); onUnmounted(() => { if (window.__docLinkHandler) { - document.removeEventListener('click', window.__docLinkHandler); + document.removeEventListener("click", window.__docLinkHandler); delete window.__docLinkHandler; } }); @@ -367,7 +374,9 @@ watch(selected, () => {