Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ h6::before { color: var(--maincolor); content: '###### '; }

.toc {
background-color: #ececec;
border-radius: 5px;
/* border-radius: 5px; */
opacity: 0.20;
color: #232333;
flex: 0 0 auto;
height: auto;
Expand All @@ -184,6 +185,11 @@ h6::before { color: var(--maincolor); content: '###### '; }
padding: 10px;
position: sticky;
top: 20px;
transition: opacity 0.1s cubic-bezier(0.4, 0, 1, 1);
}

.toc:hover {
opacity: 1;
}

/* Footer */
Expand Down
28 changes: 27 additions & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,36 @@ <h1 class="title">{{ .Title }}</h1>

<!-- TOC -->
{{ if isset .Params "toc" }}
<div class="toc">
<div class="toc" id="post-toc">
<strong>Table of contents:</strong>
{{ .TableOfContents }}
</div>

<script>
let toc_ = document.getElementById("post-toc")
let button_ = document.getElementById("head_toc_switch")
let toc_preference = localStorage.getItem("toc_preference")

if (toc_preference == "hide") {
toc_.style.display = "none"
button_.innerText = "Show Toc"
}

function function_display_toc() {

if (toc_.style.display == "none") {
toc_.style.display = ""
button_.innerText = "Hide Toc"
localStorage.setItem("toc_preference", "show")
} else {
toc_.style.display = "none"
button_.innerText = "Show Toc"
localStorage.setItem("toc_preference", "hide")
}
}

document.getElementById("in_posts").style.display = "inline"
</script>
{{ end }}
</div>

Expand Down
6 changes: 6 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
{{ range .Site.Menus.main }}
<a href="{{ .URL }}">{{ .Name }}</a>
{{ end }}

<div id="in_posts" style="display: none;">
<span>|</span>
<a href="javascript:function_display_toc()" id="head_toc_switch">Hide TOC</a>
</div>

{{ if eq .Site.Params.mode "toggle" -}}
| <span id="dark-mode-toggle" onclick="toggleTheme()">{{template "feathericon" (dict "UseCDN" .Site.Params.useCDN "Icon" "sun") }}</span>
<script src="{{ absURL "js/themetoggle.js" }}"></script>
Expand Down