45 lines
2 KiB
HTML
45 lines
2 KiB
HTML
{{- $currentPage := . -}}
|
|
{{- $graph := $currentPage.Store.Get "graph" -}}
|
|
{{- $allSections := slice -}}
|
|
{{- $menuPagePaths := dict -}}
|
|
{{ range $menuPrefix, $pagePath := $graph }}
|
|
{{- if eq $menuPrefix "no-prefix" -}}
|
|
{{- $sectionsWithPagePaths := partial "GetSectionsWithPagePaths.html" $pagePath -}}
|
|
{{if index $sectionsWithPagePaths "sections" }}
|
|
{{- $allSections = $allSections | append (index $sectionsWithPagePaths "sections") -}}
|
|
{{- range $section, $pagePaths := $sectionsWithPagePaths -}}
|
|
{{- if ne $section "sections" -}}
|
|
{{- $menuPagePaths = merge $menuPagePaths (dict $section (index $sectionsWithPagePaths $section)) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- $menuPrefix := printf "%s_" $menuPrefix -}}
|
|
{{- $allSections = $allSections | append $menuPrefix -}}
|
|
{{- $pagePaths := index $menuPagePaths $pagePath|default slice -}}
|
|
{{- $pagePaths = $pagePaths|append $pagePath -}}
|
|
{{- $menuPagePaths = merge $menuPagePaths (dict $menuPrefix $pagePaths) -}}
|
|
{{- end -}}
|
|
{{ end }}
|
|
{{- $allSections = ($allSections|uniq|sort) -}}
|
|
|
|
{{- $orderedSections := slice -}}
|
|
{{- range $key := site.Params.Sandpoints.graphMenuOrder -}}
|
|
{{- if in $allSections $key -}}
|
|
{{- $orderedSections = $orderedSections|append $key -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- $orderedSections := ($orderedSections|append $allSections)|uniq -}}
|
|
|
|
{{- range $section := $orderedSections -}}
|
|
{{- if strings.HasSuffix $section "_" -}}
|
|
{{- $menuPrefix := strings.TrimSuffix "_" $section -}}
|
|
{{- range $menuSection, $pagePaths := partial "GetSectionsWithPagePaths.html" (index $menuPagePaths $section) -}}
|
|
{{- if eq $menuSection "sections" -}}{{- continue -}}{{- end -}}
|
|
{{- partial "graph-menu.html" (dict "cursiveMenuPrefix" $menuPrefix "menuSection" $menuSection "pagePaths" $pagePaths) -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- partial "graph-menu.html" (dict "cursiveMenuPrefix" "" "menuSection" $section "pagePaths" (index $menuPagePaths $section)) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|