{{- $context := .context -}} {{- $no_sidebar := .no_sidebar | default true -}} {{- $pad_sidebar := true -}} {{- $sidebar_dynamic_class := cond $no_sidebar (cond $pad_sidebar "lg:hidden xl:block" "lg:hidden") "lg:sticky" -}} {{- $root_section := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}} {{- $page_url := $context.RelPermalink -}} {{/* Only replace explicit mobile menu links with automated links for Docs pages */}} {{ if not $no_sidebar }} {{/* Classes appended to `hb-sidebar-mobile-menu` are modified via sidebar JS, so do not @apply them to `hb-sidebar-mobile-menu` */}} {{ end }} {{- define "menu-links" -}} {{ template "link-tree" (dict "context" .context "level" 0 "page" .page "pageURL" .pageURL "toc" (.toc | default false)) }} {{- end -}} {{- define "link-tree" -}} {{- if ge .level 4 -}} {{- return -}} {{- end -}} {{- $context := .context -}} {{- $page := .page }} {{- $page_url := .page.RelPermalink -}} {{- $level := .level -}} {{- $toc := .toc | default false -}} {{- with $items := union .context.RegularPages .context.Sections -}} {{- $items = where $items "Params.sidebar.hidden" "!=" true -}} {{- if eq $level 0 -}} {{- range $items.ByWeight }} {{- $active := eq $page_url .RelPermalink -}} {{- $is_expanded := or (.Params.sidebar.open) (.IsAncestor $page) $active | default false }}
  • {{- template "custom-menu-link" dict "context" . "active" $active "title" .LinkTitle "link" .RelPermalink -}} {{- if and $toc $active -}} {{- template "mobile-toc" dict "page" . -}} {{- end -}} {{- template "link-tree" dict "context" . "page" $page "pageURL" $page_url "level" (add $level 1) "toc" $toc -}}
  • {{- end -}} {{- else -}}
    {{- end -}} {{- end }} {{- end -}} {{- define "mobile-toc" -}} {{ $page := .page }} {{ with $page.Fragments.Headings }} {{ end }} {{- end -}} {{- define "custom-menu-links" -}} {{- range site.Menus.sidebar -}} {{- $name := .Name -}} {{ if eq .Params.type "separator" }}
  • {{ $name }}
  • {{ else }}
  • {{ template "custom-menu-link" dict "active" false "title" $name "link" (.URL | relLangURL) }}
  • {{ end }} {{- end -}} {{- end -}} {{- define "custom-menu-link" -}} {{- $is_external := strings.HasPrefix .link "http" -}} {{- $open := .open | default false -}} {{- .title -}} {{- with .context }} {{- if or .RegularPages .Sections }} {{- end }} {{ end -}} {{- end -}}