add: expandable ToC
This commit is contained in:
parent
e319a2414e
commit
528a25fed5
4 changed files with 47 additions and 9 deletions
|
@ -1,9 +1,19 @@
|
|||
{{ $toc := and ($.Site.Params.toc) (ge .WordCount $.Site.Params.tocWordCount) }}
|
||||
|
||||
{{ if isset .Params "toc" }}
|
||||
{{ $toc = .Params.toc }}
|
||||
{{ $toc := and ($.Site.Params.toc) (ge .WordCount $.Site.Params.tocWordCount) }} {{ if isset .Params "toc" }} {{ $toc = .Params.toc }} {{ end }} {{ if $toc }}
|
||||
<details class="toc">
|
||||
<summary>Table of Contents</summary>
|
||||
<div class="inner">{{ .TableOfContents }}</div>
|
||||
</details>
|
||||
{{ end }}
|
||||
|
||||
{{ if $toc }}
|
||||
{{ .TableOfContents }}
|
||||
{{ end }}
|
||||
<script>
|
||||
document.querySelector(".toc").addEventListener("click", function () {
|
||||
event.preventDefault();
|
||||
if (this.open) {
|
||||
this.open = false;
|
||||
this.classList.remove("expanded");
|
||||
} else {
|
||||
this.open = true;
|
||||
this.classList.add("expanded");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue