Skip to content

Commit

Permalink
fix: retrieve menu data for sections (list pages)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdumay committed Jan 9, 2025
1 parent eccef02 commit bf599d2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions layouts/partials/utilities/GetMenu.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{{- $page := .page -}}
{{- $version := .version -}}
{{- $sidebarFilename := "" -}}
{{- $path := "" -}}

{{- $menu := "" -}}
{{- if $page.IsPage -}}
{{- if or $page.IsPage $page.IsSection -}}
{{/* Try filename with language extension */}}
{{- $sidebarFilename = printf "%s-%s.%s" $page.Section $version $page.Lang -}}
{{- $menu = index site.Data $sidebarFilename -}}
{{- $path = printf "%s-%s.%s" $page.Section $version $page.Lang -}}
{{- $menu = index site.Data $path -}}
{{ if not $menu }}
{{- $sidebarFilename = printf "%s.%s" $page.Section $page.Lang -}}
{{ $menu = index site.Data $sidebarFilename }}
{{- $path = printf "%s.%s" $page.Section $page.Lang -}}
{{ $menu = index site.Data $path }}
{{ end }}

{{/* Try filename without language extension */}}
{{ if not $menu }}
{{- $sidebarFilename = printf "%s-%s" $page.Section $version -}}
{{- $menu = index site.Data $sidebarFilename -}}
{{- $path = printf "%s-%s" $page.Section $version -}}
{{- $menu = index site.Data $path -}}
{{ end }}
{{ if not $menu }}
{{- $sidebarFilename = $page.Section -}}
{{ $menu = index site.Data $sidebarFilename }}
{{- $path = $page.Section -}}
{{ $menu = index site.Data $path }}
{{ end }}
{{- end -}}

{{ if $menu }}{{ with $sidebarFilename }}{{ $page.Scratch.Set "sidebarFilename" (path.Join "data" .) }}{{ end }}{{ end -}}
{{ if $menu }}{{ with $path }}{{ $page.Scratch.Set "sidebarFilename" (path.Join "data" .) }}{{ end }}{{ end -}}

{{- return $menu -}}

0 comments on commit bf599d2

Please sign in to comment.