2018-09-17 18:29:36 +02:00
|
|
|
<!-- Put configured sections list to .Scratch -->
|
2018-09-18 01:35:54 +02:00
|
|
|
{{ template "book-get-root-section" . }}
|
2018-09-05 16:22:04 +02:00
|
|
|
|
2018-09-18 01:35:54 +02:00
|
|
|
{{- range .Scratch.Get "BookSections" -}}
|
|
|
|
{{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }}
|
|
|
|
{{- end -}}
|
2018-09-17 18:29:36 +02:00
|
|
|
|
2018-09-18 01:35:54 +02:00
|
|
|
{{ define "book-section" }} <!-- Single section of menu (recursive) -->
|
|
|
|
<ul>
|
|
|
|
{{ range .Section.Sections }}
|
2018-09-28 01:12:07 +02:00
|
|
|
<li {{- if .Params.bookflatsection}} class="flat" {{ end }}>
|
2018-09-17 18:29:36 +02:00
|
|
|
{{- if .Content -}}
|
2018-09-18 01:35:54 +02:00
|
|
|
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
2018-09-17 18:29:36 +02:00
|
|
|
{{- else -}}
|
|
|
|
{{- template "title" . -}}
|
|
|
|
{{- end -}}
|
2018-09-18 01:35:54 +02:00
|
|
|
|
|
|
|
{{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
|
|
|
</li>
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ range .Section.Pages }}
|
|
|
|
<li>
|
|
|
|
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
|
|
|
</li>
|
2018-09-17 18:29:36 +02:00
|
|
|
{{ end }}
|
2018-09-18 01:35:54 +02:00
|
|
|
</ul>
|
|
|
|
{{ end }}
|
2018-09-17 18:29:36 +02:00
|
|
|
|
2018-09-18 01:35:54 +02:00
|
|
|
{{ define "book-page-link" }}
|
|
|
|
{{- with .Page -}}
|
|
|
|
<a href="{{ .RelPermalink }}" {{- if eq $.CurrentPage .Permalink }} class="active"{{ end }}>
|
|
|
|
{{- template "title" . -}}
|
|
|
|
</a>
|
|
|
|
{{- end -}}
|
2018-09-05 16:22:04 +02:00
|
|
|
{{ end }}
|
|
|
|
|
2018-09-17 18:29:36 +02:00
|
|
|
{{ define "book-get-root-section" }}
|
2018-09-18 01:35:54 +02:00
|
|
|
<!-- Complex logic to guess page title without .Title specified -->
|
2018-09-17 18:29:36 +02:00
|
|
|
{{ $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 }}
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|