2018-09-17 18:29:36 +02:00
|
|
|
<!-- Put configured sections list to .Scratch -->
|
|
|
|
{{ template "book-get-root-section" . }}
|
2018-09-05 16:22:04 +02:00
|
|
|
|
2018-09-12 14:36:16 +02:00
|
|
|
<ul>
|
2018-09-05 16:22:04 +02:00
|
|
|
{{ range .Scratch.Get "BookSections" }}
|
|
|
|
{{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }}
|
|
|
|
{{ end }}
|
2018-09-12 14:36:16 +02:00
|
|
|
</ul>
|
2018-09-05 16:22:04 +02:00
|
|
|
|
|
|
|
<!-- Single section of menu (recursive) -->
|
|
|
|
{{ define "book-section" }}
|
2018-09-11 16:51:27 +02:00
|
|
|
<li {{ if .Section.Params.booktopsection }}class="book-nav-section"{{ end }}>
|
2018-09-17 18:29:36 +02:00
|
|
|
|
|
|
|
{{ with .Section}}
|
|
|
|
{{- if .Content -}}
|
|
|
|
<a href="{{ .RelPermalink }}">{{- template "title" . -}}</a>
|
|
|
|
{{- else -}}
|
|
|
|
{{- template "title" . -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{ end }}
|
|
|
|
|
2018-09-11 16:51:27 +02:00
|
|
|
<ul>
|
2018-09-05 16:22:04 +02:00
|
|
|
{{ range .Section.Sections }}
|
|
|
|
{{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
|
|
|
{{ end }}
|
|
|
|
{{ range .Section.Pages }}
|
2018-09-11 16:51:27 +02:00
|
|
|
<li>
|
|
|
|
<a href="{{ .RelPermalink }}" class="{{ if eq $.CurrentPage .Permalink }}active{{ end }}">
|
2018-09-17 18:29:36 +02:00
|
|
|
{{- template "title" . -}}
|
2018-09-05 16:22:04 +02:00
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
{{ end }}
|
|
|
|
|
2018-09-17 18:29:36 +02:00
|
|
|
{{ define "book-get-root-section" }}
|
|
|
|
<!-- Complex logic to guess page title without .Title specified -->
|
|
|
|
{{ $bookSection := default "docs" .Site.Params.BookSection }}
|
|
|
|
{{ if eq $bookSection "*" }}
|
|
|
|
{{ .Scratch.Set "BookSections" .Site.Sections }}
|
2018-09-12 14:36:16 +02:00
|
|
|
{{ else }}
|
2018-09-17 18:29:36 +02:00
|
|
|
{{ $bookSections := where .Site.Sections "Section" $bookSection }}
|
|
|
|
{{ .Scratch.Set "BookSections" $bookSections }}
|
2018-09-05 16:22:04 +02:00
|
|
|
|
2018-09-17 18:29:36 +02:00
|
|
|
{{ if eq (len $bookSections) 1 }}
|
|
|
|
{{ $singleSection := index $bookSections 0 }}
|
|
|
|
{{ .Scratch.Set "BookSections" $singleSection.Sections }}
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|