From cb89cce183215f6a8edcb6d166875e2982586002 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sat, 17 Jun 2023 21:36:06 +0000
Subject: [PATCH] basic left,right layout
---
quartz/components/scripts/toc.inline.ts | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/quartz/components/scripts/toc.inline.ts b/quartz/components/scripts/toc.inline.ts
index 405a21f..105889d 100644
--- a/quartz/components/scripts/toc.inline.ts
+++ b/quartz/components/scripts/toc.inline.ts
@@ -14,19 +14,24 @@
}
})
-function toggleCollapsible(this: HTMLElement) {
+function toggleToc(this: HTMLElement) {
this.classList.toggle("collapsed")
const content = this.nextElementSibling as HTMLElement
content.classList.toggle("collapsed")
content.style.maxHeight = content.style.maxHeight === "0px" ? content.scrollHeight + "px" : "0px"
}
-document.addEventListener("nav", () => {
+function setupToc() {
const toc = document.getElementById("toc")!
const content = toc.nextElementSibling as HTMLElement
content.style.maxHeight = content.scrollHeight + "px"
- toc.removeEventListener("click", toggleCollapsible)
- toc.addEventListener("click", toggleCollapsible)
+ toc.removeEventListener("click", toggleToc)
+ toc.addEventListener("click", toggleToc)
+}
+
+window.addEventListener("resize", setupToc)
+document.addEventListener("nav", () => {
+ setupToc()
// update toc entry highlighting
observer.disconnect()
--
Gitblit v1.10.0