2019-04-22 17:17:39 +00: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 14:22:04 +00:00
|
|
|
|
2018-09-17 16:29:36 +00:00
|
|
|
|
2019-04-22 17:17:39 +00: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 }}
|
|
|
|
{{ template "book-section-children" (dict "Section" . "CurrentPage" $.Permalink) }}
|
|
|
|
{{ end }}
|
|
|
|
{{ else }}
|
2018-09-17 23:35:54 +00:00
|
|
|
<ul>
|
2019-04-22 17:17:39 +00:00
|
|
|
{{ range $sections }}
|
|
|
|
{{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }}
|
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
{{ end }}
|
2018-09-17 23:35:54 +00:00
|
|
|
|
2019-04-22 17:17:39 +00:00
|
|
|
{{ define "book-section" }}
|
|
|
|
{{ with .Section }}
|
|
|
|
<li {{ if .Params.bookFlatSection}} class="book-section-flat" {{ end }}>
|
|
|
|
{{ if .Content }}
|
|
|
|
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
|
|
|
{{ else }}
|
|
|
|
<span>{{ template "title" . }}</span>
|
2018-09-17 23:35:54 +00:00
|
|
|
{{ end }}
|
|
|
|
|
2019-04-22 17:17:39 +00:00
|
|
|
{{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
|
|
|
</li>
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ define "book-section-children" }}
|
|
|
|
{{ with .Section }}
|
|
|
|
<ul>
|
|
|
|
{{ range .Sections }}
|
|
|
|
{{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
|
|
|
{{ end }}
|
|
|
|
{{ range .Pages }}
|
2018-09-17 23:35:54 +00:00
|
|
|
<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 }}
|
2019-04-22 17:17:39 +00:00
|
|
|
{{ end }}
|
2018-09-17 16:29:36 +00:00
|
|
|
|
2018-09-17 23:35:54 +00:00
|
|
|
{{ define "book-page-link" }}
|
2019-04-22 17:17:39 +00:00
|
|
|
{{ 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 }}
|