2020-02-16 22:40:02 +00:00
|
|
|
{{ $tocLevels := default (default 6 .Site.Params.GeekdocToC) .Page.Params.GeekdocToC }}
|
|
|
|
|
|
|
|
{{ if $tocLevels }}
|
2022-01-06 12:58:10 +00:00
|
|
|
<div class="gdoc-toc gdoc-toc__level--{{ $tocLevels }}">
|
2020-04-14 23:09:53 +00:00
|
|
|
{{ template "toc-tree" dict "sect" .Page.Pages }}
|
|
|
|
</div>
|
2020-02-16 22:40:02 +00:00
|
|
|
{{ end }}
|
|
|
|
|
2022-01-06 12:58:10 +00:00
|
|
|
|
2020-02-16 22:40:02 +00:00
|
|
|
<!-- templates -->
|
|
|
|
{{ define "toc-tree" }}
|
2020-04-14 23:09:53 +00:00
|
|
|
<ul>
|
|
|
|
{{ range .sect.GroupBy "Weight" }}
|
|
|
|
{{ range .ByTitle }}
|
2022-01-06 12:58:10 +00:00
|
|
|
{{ if or (not .Params.GeekdocHidden) (not (default true .Params.GeekdocHiddenTocTree)) }}
|
|
|
|
<li>
|
|
|
|
{{ if or .Content .Params.GeekdocFlatSection }}
|
|
|
|
<span>
|
|
|
|
<a href="{{ .RelPermalink }}" class="gdoc-toc__entry">
|
2022-02-07 09:57:43 +00:00
|
|
|
{{ partial "utils/title" . }}{{ with .Params.GeekdocDescription }}:{{ end }}
|
2022-01-06 12:58:10 +00:00
|
|
|
</a>
|
|
|
|
{{ with .Params.GeekdocDescription }}{{ . }}{{ end }}
|
|
|
|
</span>
|
|
|
|
{{ else }}
|
|
|
|
<span>
|
2022-02-07 09:57:43 +00:00
|
|
|
{{ partial "utils/title" . }}{{ with .Params.GeekdocDescription }}
|
|
|
|
: {{ . }}
|
|
|
|
{{ end }}
|
2022-01-06 12:58:10 +00:00
|
|
|
</span>
|
|
|
|
{{ end }}
|
2020-02-16 22:40:02 +00:00
|
|
|
|
2022-01-06 12:58:10 +00:00
|
|
|
{{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
|
|
|
|
{{ if and (ne $numberOfPages 0) (not .Params.GeekdocFlatSection) }}
|
|
|
|
{{ template "toc-tree" dict "sect" .Pages }}
|
|
|
|
{{ end }}
|
|
|
|
</li>
|
|
|
|
{{ end }}
|
2020-04-14 23:09:53 +00:00
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
</ul>
|
2020-02-16 22:40:02 +00:00
|
|
|
{{ end }}
|