{{ $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 }} {{ $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" $) }} {{ end }} {{ else }} {{ end }} {{ define "book-section" }} {{ with .Section }}
  • {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }} {{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }}
  • {{ end }} {{ end }} {{ define "book-section-children" }} {{ $ancestor := .Section.IsAncestor .CurrentPage }} {{ $collapsed := .Section.Params.bookCollapseSection }} {{ if or $ancestor (not $collapsed) }} {{ with .Section }} {{ end }} {{ end }} {{ end }} {{ define "book-page-link" }} {{ with .Page }} {{ if .Content }} {{- partial "docs/title" . -}} {{ else }} {{- partial "docs/title" . -}} {{ end }} {{ end }} {{ end }}