| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <!-- Put configured sections list to .Scratch -->
- {{ template "book-get-root-section" . }}
- {{- range .Scratch.Get "BookSections" -}}
- {{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }}
- {{- end -}}
- {{ define "book-section" }} <!-- Single section of menu (recursive) -->
- <ul {{ if .Expanded }}class="expanded"{{ end }}>
- {{ range (.Section.Pages.ByParam "Title").ByParam "Weight" }}
- {{ if and (eq .Kind "section") (or (gt (len .Pages) 0) (gt (len .Sections) 0) ) }}
- <li class="section">
- {{ $expanded := in $.CurrentPage .Permalink }}
- <div class="section-link">
- <img src="{{ "svg/clr-icon-angle.svg" | relURL }}" class="section-icon {{ if $expanded}}expanded{{ end }}" />
- {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
- </div>
- {{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage "Expanded" $expanded) }}
- </li>
- {{ else }}
- <li>
- {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
- </li>
- {{ end }}
- {{ end }}
- </ul>
- {{ end }}
- {{ define "book-page-link" }}
- {{- with .Page -}}
- <a href="{{ .RelPermalink }}" {{- if eq $.CurrentPage .Permalink }} class="active"{{ end }}>
- {{- template "title" . -}}
- </a>
- {{- end -}}
- {{ end }}
- {{ define "book-get-root-section" }}
- <!-- Complex logic to guess page title without .Title specified -->
- {{ $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 }}
- {{ end }}
|