uci-hugo-doc/layouts/shortcodes/toc-tree.html

40 lines
1.3 KiB
HTML
Raw Normal View History

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