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