layouts/_partials/sidebar/sections.html
{{- /* 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 }}
{{- if .Permalink }} {{/* If the link is not empty, use it */}} {{ template "renderTitle" . }} {{- else }} {{/* Otherwise, just expand the section */}} {{ template "renderTitle" . }} {{- end }} {{/* Only show expand group button if section has children */}} {{- $hasChildren := gt (len (where .Pages "Params.sitemap" "ne" "false")) 0 }} {{- if $hasChildren }} {{ partialCached "icon" "arrow_drop_down" "arrow_drop_down" }} {{ partialCached "icon" "arrow_drop_up" "arrow_drop_up" }} {{- end }}
{{ template "renderChildren" . }} {{ 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 }}