From 8020bda9fcccd37862592422c48b9d93c0bb3473 Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Sat, 1 Mar 2025 15:08:54 +0100 Subject: [PATCH] Respect configuration --- quartz/components/scripts/explorer.inline.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/quartz/components/scripts/explorer.inline.ts b/quartz/components/scripts/explorer.inline.ts index 37aa0f271..db697a2a6 100644 --- a/quartz/components/scripts/explorer.inline.ts +++ b/quartz/components/scripts/explorer.inline.ts @@ -103,6 +103,12 @@ function setupExplorer() { } } + const currentPath = document.getElementsByTagName("body")[0].getAttribute("data-slug") ?? "" + const currentPathInExplorer = document.querySelector(`a[data-for="${currentPath}"]`) + if (currentPathInExplorer && explorer.dataset.highlightpath === "true") { + currentPathInExplorer.classList.add("highlight-path") + } + // Add click handler to main explorer window.addCleanup(() => explorer.removeEventListener("click", toggleExplorer)) explorer.addEventListener("click", toggleExplorer) @@ -169,7 +175,6 @@ window.addEventListener("resize", setupExplorer) document.addEventListener("nav", () => { const explorer = document.querySelector("#mobile-explorer") - const currentPath = document.getElementsByTagName("body")[0].getAttribute("data-slug") ?? "" if (explorer) { explorer.classList.add("collapsed") const content = explorer.nextElementSibling?.nextElementSibling as HTMLElement @@ -177,10 +182,6 @@ document.addEventListener("nav", () => { content.classList.add("collapsed") content.classList.toggle("explorer-viewmode") } - const currentPathInExplorer = document.querySelector(`a[data-for="${currentPath}"]`) - if (currentPathInExplorer) { - currentPathInExplorer.classList.add("highlight-path") - } } setupExplorer()