2019-04-22 19:17:39 +02:00
|
|
|
{{ $bookSection := default "docs" .Site.Params.BookSection }}
|
|
|
|
{{ if eq $bookSection "*" }}
|
|
|
|
{{ .Scratch.Set "BookSections" .Site.Sections }}
|
|
|
|
{{ else }}
|
|
|
|
{{ $bookSections := where .Site.Sections "Section" $bookSection }}
|
|
|
|
{{ .Scratch.Set "BookSections" $bookSections }}
|
|
|
|
{{ end }}
|
2018-09-05 16:22:04 +02:00
|
|
|
|
2018-09-17 18:29:36 +02:00
|
|
|
|
2019-04-22 19:17:39 +02:00
|
|
|
{{ $sections := .Scratch.Get "BookSections" }}
|
|
|
|
{{/* If there is only one section to render then render its children, else render all sections */}}
|
|
|
|
{{ if eq (len $sections) 1 }}
|
|
|
|
{{ with index $sections 0 }}
|
2019-10-09 01:00:26 +02:00
|
|
|
{{ template "book-section-children" (dict "Section" . "CurrentPage" $) }}
|
2019-04-22 19:17:39 +02:00
|
|
|
{{ end }}
|
|
|
|
{{ else }}
|
2018-09-18 01:35:54 +02:00
|
|
|
<ul>
|
2019-11-10 00:23:06 +01:00
|
|
|
{{ range where $sections "Params.bookHidden" "!=" true }}
|
2019-10-09 01:00:26 +02:00
|
|
|
{{ template "book-section" (dict "Section" . "CurrentPage" $) }}
|
2019-04-22 19:17:39 +02:00
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
{{ end }}
|
2018-09-18 01:35:54 +02:00
|
|
|
|
2019-04-22 19:17:39 +02:00
|
|
|
{{ define "book-section" }}
|
|
|
|
{{ with .Section }}
|
2020-02-29 21:15:52 +01:00
|
|
|
<li {{- if .Params.BookFlatSection }} class="book-section-flat" {{ end }}>
|
|
|
|
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
2019-04-22 19:17:39 +02:00
|
|
|
{{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
|
|
|
</li>
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ define "book-section-children" }}
|
2019-10-09 01:00:26 +02:00
|
|
|
{{ $ancestor := .Section.IsAncestor .CurrentPage }}
|
|
|
|
{{ $collapsed := .Section.Params.bookCollapseSection }}
|
|
|
|
|
|
|
|
{{ if or $ancestor (not $collapsed) }}
|
|
|
|
{{ with .Section }}
|
2019-04-22 19:17:39 +02:00
|
|
|
<ul>
|
2019-08-29 06:53:19 +02:00
|
|
|
{{ range where .Pages "Params.bookhidden" "!=" "true" }}
|
2020-03-30 18:00:15 +02:00
|
|
|
{{ if .IsSection }}
|
2019-08-29 06:53:19 +02:00
|
|
|
{{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
2020-03-30 18:00:15 +02:00
|
|
|
{{ else if and .IsPage .Content }}
|
2019-08-29 06:53:19 +02:00
|
|
|
<li>
|
|
|
|
{{- template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) -}}
|
|
|
|
</li>
|
|
|
|
{{ end }}
|
2018-09-17 18:29:36 +02:00
|
|
|
{{ end }}
|
2018-09-18 01:35:54 +02:00
|
|
|
</ul>
|
2019-10-09 01:00:26 +02:00
|
|
|
{{ end }}
|
2018-09-18 01:35:54 +02:00
|
|
|
{{ end }}
|
2019-10-09 01:00:26 +02:00
|
|
|
|
2019-04-22 19:17:39 +02:00
|
|
|
{{ end }}
|
2018-09-17 18:29:36 +02:00
|
|
|
|
2018-09-18 01:35:54 +02:00
|
|
|
{{ define "book-page-link" }}
|
2019-04-22 19:17:39 +02:00
|
|
|
{{ with .Page }}
|
2020-02-29 21:15:52 +01:00
|
|
|
{{ if .Content }}
|
|
|
|
<a href="{{ .RelPermalink }}" class="
|
2020-03-01 00:49:20 +01:00
|
|
|
{{- if and .Params.bookCollapseSection .IsSection }}collapsed {{ end }}
|
2020-03-30 18:00:15 +02:00
|
|
|
{{- if eq $.CurrentPage.RelPermalink .RelPermalink }}active{{ end }}">
|
2020-02-29 21:15:52 +01:00
|
|
|
{{- partial "docs/title" . -}}
|
2019-04-22 19:17:39 +02:00
|
|
|
</a>
|
2020-02-29 21:15:52 +01:00
|
|
|
{{ else }}
|
|
|
|
<span>{{- partial "docs/title" . -}}</span>
|
|
|
|
{{ end }}
|
2019-04-22 19:17:39 +02:00
|
|
|
{{ end }}
|
2018-09-05 16:22:04 +02:00
|
|
|
{{ end }}
|