{{- /* This template recursively renders the sidebar navigation, grouping pages by `Params.sidebar.groups`. Highlights: - Supports hierarchical navigation with collapsible sections (`renderList` template). - Dynamically applies current page highlighting and expanded states. - Handles external links via `Params.sidebar.goto` in `renderSingle`. - Requires `Params.sitemap` and `Params.sidebar` for filtering and behavior. */ -}} {{ define "renderChildren" }} {{- $pages := where .Pages "Params.sitemap" "ne" "false" }} {{- if .Params.sidebar.reverse }} {{ $pages = .Pages.Reverse }} {{- end }} {{- $ungrouped := where $pages "Params.sidebar.group" "==" nil }} {{- range $ungrouped }} {{- if .IsSection }} {{- template "renderList" . }} {{- else }} {{- template "renderSingle" . }} {{- end }} {{- end }} {{- range .Params.sidebar.groups }} {{- end }} {{ end }} {{/* Recursive template for sidebar items */}} {{ define "renderList" }} {{ $isCurrent := eq page . }} {{ $expanded := or $isCurrent (page.IsDescendant .) }}
  • {{- if .Permalink }} {{/* If the link is not empty, use it */}} {{ template "renderTitle" . }} {{- else }} {{/* Otherwise, just expand the section */}} {{- end }}
  • {{ end }} {{ define "renderSingle" }} {{- if .Params.sidebar.goto }}
  • {{ template "renderTitle" . }}
  • {{- else }} {{ $isCurrent := eq page . }}
  • {{ template "renderTitle" . }}
  • {{- end }} {{ end }} {{ define "renderTitle" }} {{ .LinkTitle }} {{- with .Params.sidebar.badge }} {{- partial "components/badge.html" (dict "color" .color "content" .text) }} {{- end }} {{ end }}