From e98d97a271857efe14e6f15d8971d452b2d1a2d5 Mon Sep 17 00:00:00 2001
From: Felix Nie <hongtuo.nie@u.nus.edu>
Date: Wed, 07 May 2025 19:56:18 +0000
Subject: [PATCH] feat(i18n): readermode translations and icon (#1961)
---
quartz/components/scripts/toc.inline.ts | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/quartz/components/scripts/toc.inline.ts b/quartz/components/scripts/toc.inline.ts
index a63da8d..4148fa2 100644
--- a/quartz/components/scripts/toc.inline.ts
+++ b/quartz/components/scripts/toc.inline.ts
@@ -1,13 +1,13 @@
const observer = new IntersectionObserver((entries) => {
for (const entry of entries) {
const slug = entry.target.id
- const tocEntryElement = document.querySelector(`a[data-for="${slug}"]`)
+ const tocEntryElements = document.querySelectorAll(`a[data-for="${slug}"]`)
const windowHeight = entry.rootBounds?.height
- if (windowHeight && tocEntryElement) {
+ if (windowHeight && tocEntryElements.length > 0) {
if (entry.boundingClientRect.y < windowHeight) {
- tocEntryElement.classList.add("in-view")
+ tocEntryElements.forEach((tocEntryElement) => tocEntryElement.classList.add("in-view"))
} else {
- tocEntryElement.classList.remove("in-view")
+ tocEntryElements.forEach((tocEntryElement) => tocEntryElement.classList.remove("in-view"))
}
}
}
@@ -25,7 +25,7 @@
}
function setupToc() {
- for (const toc of document.querySelectorAll(".toc")) {
+ for (const toc of document.getElementsByClassName("toc")) {
const button = toc.querySelector(".toc-header")
const content = toc.querySelector(".toc-content")
if (!button || !content) return
--
Gitblit v1.10.0