From dcaf806190efe1dde3d8392292555b76ace07bdb Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Mon, 10 Mar 2025 18:44:47 +0000
Subject: [PATCH] feat: support non-singleton darkmode
---
quartz/components/scripts/toc.inline.ts | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/quartz/components/scripts/toc.inline.ts b/quartz/components/scripts/toc.inline.ts
index a518c10..6c5ad1c 100644
--- a/quartz/components/scripts/toc.inline.ts
+++ b/quartz/components/scripts/toc.inline.ts
@@ -25,16 +25,15 @@
}
function setupToc() {
- const toc = document.getElementById("toc")
- if (toc) {
- const content = toc.nextElementSibling as HTMLElement | undefined
- if (!content) return
- toc.addEventListener("click", toggleToc)
- window.addCleanup(() => toc.removeEventListener("click", toggleToc))
+ for (const toc of document.getElementsByClassName("toc")) {
+ const button = toc.querySelector(".toc-header")
+ const content = toc.querySelector(".toc-content")
+ if (!button || !content) return
+ button.addEventListener("click", toggleToc)
+ window.addCleanup(() => button.removeEventListener("click", toggleToc))
}
}
-window.addEventListener("resize", setupToc)
document.addEventListener("nav", () => {
setupToc()
--
Gitblit v1.10.0