2025-03-30 11:49:43 +02:00
|
|
|
{{- $currentPage := . -}}
|
2025-04-18 12:05:39 +02:00
|
|
|
{{- $currentEntry := dict -}}
|
2025-03-30 11:49:43 +02:00
|
|
|
{{- $menuPrefix := "" -}}
|
|
|
|
{{- $section := "" -}}
|
2025-03-31 15:49:04 +02:00
|
|
|
{{- range $sectionMaybe, $pagesMaybe := $currentPage.Params -}}
|
2025-03-30 11:49:43 +02:00
|
|
|
{{- if strings.Contains $sectionMaybe "_" -}}
|
|
|
|
{{- $sectionsSlice := split (strings.TrimPrefix "_" $sectionMaybe) "_" -}}
|
|
|
|
{{- if gt (len $sectionsSlice) 0 -}}
|
|
|
|
{{- $pluralSection := index (last 1 $sectionsSlice) 0 -}}
|
2025-04-03 16:24:20 +02:00
|
|
|
{{- $section = partial "GetSingularSectionName.html" $pluralSection -}}
|
2025-04-18 12:05:39 +02:00
|
|
|
{{- with (where site.Pages "Section" $section) -}}
|
2025-03-30 11:49:43 +02:00
|
|
|
{{- $menuPrefix = "no-prefix" -}}
|
|
|
|
{{- if gt (len $sectionsSlice) 1 -}}
|
|
|
|
{{- $menuPrefix = delimit (first (sub (len $sectionsSlice) 1) $sectionsSlice) " " -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- end -}}
|
2025-03-31 15:49:04 +02:00
|
|
|
{{- if reflect.IsSlice $pagesMaybe -}}
|
|
|
|
{{- range $pageMaybe := $pagesMaybe -}}
|
2025-05-04 15:11:06 +02:00
|
|
|
{{- $pageMaybeRelPermalink := (printf "/%s/%s" $section $pageMaybe) -}}
|
2025-03-31 15:49:04 +02:00
|
|
|
{{- $page := site.GetPage $pageMaybeRelPermalink -}}
|
|
|
|
{{- if $page -}}
|
2025-03-30 16:02:18 +02:00
|
|
|
{{- $currentPages := index $currentEntry $menuPrefix | default slice -}}
|
2025-03-31 15:49:04 +02:00
|
|
|
{{- $currentPages = $currentPages | append $page.RelPermalink -}}
|
2025-03-30 16:02:18 +02:00
|
|
|
{{- $currentEntry = merge $currentEntry (dict $menuPrefix $currentPages) -}}
|
2025-03-31 15:49:04 +02:00
|
|
|
{{- else -}}
|
2025-05-04 15:11:06 +02:00
|
|
|
{{- with $currentPage.File -}}
|
|
|
|
{{- warnf "In /%s '%s' is missing %s" .Path $sectionMaybe $pageMaybeRelPermalink -}}
|
|
|
|
{{- end -}}
|
2025-03-30 11:49:43 +02:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2025-04-18 12:05:39 +02:00
|
|
|
{{- end -}}
|
2025-03-30 11:49:43 +02:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if gt (len $currentEntry) 0 -}}
|
2025-03-30 16:02:18 +02:00
|
|
|
{{- $currentPage.Store.Set "graph" $currentEntry -}}
|
2025-03-30 11:49:43 +02:00
|
|
|
{{- end -}}
|