hugo-book-theme/layouts/partials/docs/menu-filetree.html

61 lines
1.8 KiB
HTML
Raw Normal View History

{{ $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
{{ $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-18 01:35:54 +02:00
<ul>
{{ range where $sections "Params.bookhidden" "!=" true }}
{{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }}
{{ end }}
</ul>
{{ end }}
2018-09-18 01:35:54 +02: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 }}
2019-07-15 18:25:21 +02:00
<span>{{ partial "docs/title" . }}</span>
2018-09-18 01:35:54 +02:00
{{ end }}
{{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }}
</li>
{{ end }}
{{ end }}
{{ define "book-section-children" }}
{{ with .Section }}
<ul>
{{ range where .Pages "Params.bookhidden" "!=" "true" }}
{{ if eq .Kind "section" }}
{{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }}
{{ else if and (eq .Kind "page") .Content }}
<li>
{{- template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) -}}
</li>
{{ end }}
{{ end }}
2018-09-18 01:35:54 +02:00
</ul>
{{ end }}
{{ end }}
2018-09-18 01:35:54 +02:00
{{ define "book-page-link" }}
{{ with .Page }}
<a href="{{ .RelPermalink }}" {{ if eq $.CurrentPage .Permalink }} class="active"{{ end }}>
2019-07-15 18:25:21 +02:00
{{ partial "docs/title" . }}
</a>
{{ end }}
2018-09-05 16:22:04 +02:00
{{ end }}