2024-05-01 07:46:39 +02:00
|
|
|
{{ $toc := true }}
|
2024-05-01 22:58:51 +02:00
|
|
|
{{ if isset .Params "toc" }}
|
|
|
|
{{ $toc = .Params.toc }}
|
|
|
|
{{ else }}
|
|
|
|
{{ $toc = ge .WordCount .Site.Params.tocWordCount }}
|
|
|
|
{{ if and (isset .Site.Params "toc") (not (.Site.Params.toc)) }}
|
|
|
|
{{ $toc = false }}
|
|
|
|
{{ end }}
|
2024-04-09 14:03:09 +02:00
|
|
|
{{ end }}
|
2024-03-06 06:24:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
{{ 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 }}
|
2023-07-04 21:29:38 +02:00
|
|
|
{{ end }}
|
|
|
|
|
2024-03-06 06:24:28 +01:00
|
|
|
|
2024-03-04 12:44:29 +01:00
|
|
|
<script>
|
2024-03-18 09:58:35 +01:00
|
|
|
var toc = document.querySelector(".toc");
|
|
|
|
if (toc) {
|
|
|
|
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");
|
|
|
|
}
|
2024-03-04 12:44:29 +01:00
|
|
|
}
|
2024-03-18 09:58:35 +01:00
|
|
|
});
|
|
|
|
}
|
2024-03-04 12:44:29 +01:00
|
|
|
</script>
|