diff --git a/src/module/post.js b/src/module/post.js index be6c1de..5d8f4ad 100644 --- a/src/module/post.js +++ b/src/module/post.js @@ -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); \ No newline at end of file diff --git a/templates/post.html b/templates/post.html index 00393e3..a3cd195 100644 --- a/templates/post.html +++ b/templates/post.html @@ -19,7 +19,8 @@
Post Content
-