style: hide toc when fullscreen in default
This commit is contained in:
+8
-4
@@ -3,6 +3,10 @@ import tocbot from "tocbot";
|
|||||||
let toc_icon = "☰"
|
let toc_icon = "☰"
|
||||||
let toc_close_icon = "✕"
|
let toc_close_icon = "✕"
|
||||||
|
|
||||||
|
function isTocDefaultOpen(toc) {
|
||||||
|
return toc?.dataset?.defaultOpen !== "false";
|
||||||
|
}
|
||||||
|
|
||||||
function toggleToc() {
|
function toggleToc() {
|
||||||
const toc = document.getElementById("toc");
|
const toc = document.getElementById("toc");
|
||||||
if (!toc) return;
|
if (!toc) return;
|
||||||
@@ -63,10 +67,10 @@ function setupTocVisibility() {
|
|||||||
|
|
||||||
toc.style.display = "block";
|
toc.style.display = "block";
|
||||||
|
|
||||||
if (window.innerWidth <= 1400) {
|
if (isTocDefaultOpen(toc) && window.innerWidth > 1400) {
|
||||||
toc.classList.remove('toc-visible');
|
|
||||||
} else {
|
|
||||||
toc.classList.add('toc-visible');
|
toc.classList.add('toc-visible');
|
||||||
|
} else {
|
||||||
|
toc.classList.remove('toc-visible');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,4 +166,4 @@ function registerToc() {
|
|||||||
|
|
||||||
|
|
||||||
terminal.registerRefresh(generateToc);
|
terminal.registerRefresh(generateToc);
|
||||||
terminal.registerInitFunc(registerToc);
|
terminal.registerInitFunc(registerToc);
|
||||||
+2
-1
@@ -19,7 +19,8 @@
|
|||||||
<div th:utext="${post.content.content}" id="content">Post Content</div>
|
<div th:utext="${post.content.content}" id="content">Post Content</div>
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
<nav id="toc" th:if="${theme.config.post_page.show_toc}" class="toc">
|
<nav id="toc" th:if="${theme.config.post_page.show_toc}" class="toc"
|
||||||
|
th:attr="data-default-open=${theme.config.style.fullscreen_layout ? 'false' : 'true'}">
|
||||||
<button id="toc-toggle" class="toc-toggle" aria-label="Hide Table of Contents"></button>
|
<button id="toc-toggle" class="toc-toggle" aria-label="Hide Table of Contents"></button>
|
||||||
<div id="toc-content" class="toc-content"></div>
|
<div id="toc-content" class="toc-content"></div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
Reference in New Issue
Block a user