fix: the ToC shown on non-toc pages
This commit is contained in:
parent
ada44ff67d
commit
3d600a74c3
2 changed files with 44 additions and 5 deletions
|
@ -1,10 +1,21 @@
|
|||
{{ $toc := and ($.Site.Params.toc) (ge .WordCount $.Site.Params.tocWordCount) }} {{ if isset .Params "toc" }} {{ $toc = .Params.toc }} {{ end }} {{ if $toc }}
|
||||
<details class="toc noselect">
|
||||
<summary>Table of Contents</summary>
|
||||
<div class="inner">{{ .TableOfContents }}</div>
|
||||
</details>
|
||||
{{ $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") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue