33 lines
833 B
HTML
33 lines
833 B
HTML
{{ $toc := and ($.Site.Params.toc) (ge .WordCount $.Site.Params.tocWordCount) }}
|
|
{{ if isset .Params "toc" }}
|
|
{{ $toc = .Params.toc }}
|
|
{{ end }}
|
|
|
|
|
|
{{ if $toc }}
|
|
{{ $tocContent := .TableOfContents }}
|
|
{{ if findRE "<li>" $tocContent }}
|
|
<!-- we show the toc only if we have element in .TableOfContents -->
|
|
<details class="toc noselect">
|
|
<summary>Table of Contents</summary>
|
|
<div class="inner">{{ .TableOfContents }}</div>
|
|
</details>
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
|
|
<script>
|
|
document.querySelector(".toc").addEventListener("click", function () {
|
|
if (event.target.tagName !== "A") {
|
|
event.preventDefault();
|
|
if (this.open) {
|
|
this.open = false;
|
|
this.classList.remove("expanded");
|
|
} else {
|
|
this.open = true;
|
|
this.classList.add("expanded");
|
|
}
|
|
}
|
|
});
|
|
</script>
|