style: hide toc when fullscreen in default

This commit is contained in:
Erzbir
2026-06-15 17:37:40 +08:00
parent aa318315ea
commit 72346d78d2
2 changed files with 10 additions and 5 deletions
+8 -4
View File
@@ -3,6 +3,10 @@ import tocbot from "tocbot";
let toc_icon = "☰"
let toc_close_icon = "✕"
function isTocDefaultOpen(toc) {
return toc?.dataset?.defaultOpen !== "false";
}
function toggleToc() {
const toc = document.getElementById("toc");
if (!toc) return;
@@ -63,10 +67,10 @@ function setupTocVisibility() {
toc.style.display = "block";
if (window.innerWidth <= 1400) {
toc.classList.remove('toc-visible');
} else {
if (isTocDefaultOpen(toc) && window.innerWidth > 1400) {
toc.classList.add('toc-visible');
} else {
toc.classList.remove('toc-visible');
}
}
@@ -162,4 +166,4 @@ function registerToc() {
terminal.registerRefresh(generateToc);
terminal.registerInitFunc(registerToc);
terminal.registerInitFunc(registerToc);