fix: fix formatting issue while using nested toc shortcodes (#415)

This commit is contained in:
Robert Kaussow 2022-05-22 22:07:35 +02:00 committed by GitHub
parent 6ab98d1da3
commit 6b464202c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 34 deletions

View file

@ -1,41 +1,39 @@
{{ $tocLevels := default (default 6 .Site.Params.GeekdocToC) .Page.Params.GeekdocToC }}
{{- $tocLevels := default (default 6 .Site.Params.GeekdocToC) .Page.Params.GeekdocToC }}
{{ if $tocLevels }}
{{- if $tocLevels }}
<div class="gdoc-toc gdoc-toc__level--{{ $tocLevels }}">
{{ template "toc-tree" dict "sect" .Page.Pages }}
</div>
{{ end }}
{{- end }}
<!-- templates -->
{{ define "toc-tree" }}
{{- define "toc-tree" }}
<ul>
{{ range .sect.GroupBy "Weight" }}
{{ range .ByTitle }}
{{ if or (not .Params.GeekdocHidden) (not (default true .Params.GeekdocHiddenTocTree)) }}
{{- range .sect.GroupBy "Weight" }}
{{- range .ByTitle }}
{{- if or (not .Params.GeekdocHidden) (not (default true .Params.GeekdocHiddenTocTree)) }}
<li>
{{ if or .Content .Params.GeekdocFlatSection }}
{{- if or .Content .Params.GeekdocFlatSection }}
<span>
<a href="{{ .RelPermalink }}" class="gdoc-toc__entry">
{{ partial "utils/title" . }}{{ with .Params.GeekdocDescription }}:{{ end }}
{{- partial "utils/title" . }}{{ with .Params.GeekdocDescription }}:{{ end }}
</a>
{{ with .Params.GeekdocDescription }}{{ . }}{{ end }}
{{- with .Params.GeekdocDescription }}{{ . }}{{ end }}
</span>
{{ else }}
{{- else -}}
<span>
{{ partial "utils/title" . }}{{ with .Params.GeekdocDescription }}
: {{ . }}
{{ end }}
{{- partial "utils/title" . }}{{ with .Params.GeekdocDescription }}: {{ . }}{{ end }}
</span>
{{ end }}
{{- end -}}
{{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
{{ if and (ne $numberOfPages 0) (not .Params.GeekdocFlatSection) }}
{{ template "toc-tree" dict "sect" .Pages }}
{{ end }}
{{- $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 }}
{{- end }}
{{- end }}
{{- end }}
</ul>
{{ end }}
{{- end }}