diff --git a/layouts/_default/single.html b/layouts/_default/single.html index b6587633b..c0d7ca332 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -67,5 +67,7 @@ {{ partial "layouts/in-this-section.html" . }} {{ end }} {{ $related }} - {{ $toc }} + {{ if $.Store.Get "hasToc" }} + {{ $toc }} + {{ end }} {{ end }} diff --git a/layouts/partials/layouts/toc.html b/layouts/partials/layouts/toc.html index 1a08156c1..04b3116de 100644 --- a/layouts/partials/layouts/toc.html +++ b/layouts/partials/layouts/toc.html @@ -1,5 +1,4 @@ {{ with .Fragments.Headings }} - {{ $.Store.Set "hasToc" true }}
@@ -9,15 +8,16 @@
{{ end }} {{ define "render-toc-level" }} - {{ range . }} - {{ if and .ID (or (ge .Level 2) (lt .Level 4)) }} + {{ range .h }} + {{ if and .ID (and (ge .Level 2) (le .Level 4)) }} + {{ $.p.Store.Set "hasToc" true }}
  • - {{ template "render-toc-level" . }} + {{ template "render-toc-level" (dict "h" . "p" $.p) }} {{ end }} {{ end }}