24 lines
1.1 KiB
HTML
24 lines
1.1 KiB
HTML
<!-- Nested / Iteration / Recursion -->
|
|
{{- $.Scratch.Delete "sections" -}}
|
|
{{- $.Scratch.Delete "pages" -}}
|
|
{{- $contentDir := $.Site.Params.contentDir -}}
|
|
{{- template "treeSections" (dict "$" $ "path" (cond $.Site.IsMultiLingual (printf `./%s` $contentDir) (printf `./content`))) -}}
|
|
|
|
{{- define "treeSections" -}}
|
|
{{- $ := index . "$" -}}
|
|
{{- $path := .path -}}
|
|
{{- range (readDir $path) -}}
|
|
{{- $fileName := .Name -}}
|
|
{{- if .IsDir -}}
|
|
{{- $pagePath := (cond $.Site.IsMultiLingual (strings.TrimPrefix (printf `./%s` $.Site.Params.contentDir) (printf `%s/%s` $path $fileName)) (strings.TrimPrefix "./content" (printf `%s/%s` $path $fileName))) -}}
|
|
{{- with $.Site.GetPage $pagePath -}}
|
|
{{- if and (eq .Kind "section") (in $.Site.Params.mainSections .Section) -}}
|
|
{{- $.Scratch.Add "sections" (slice $fileName) -}}
|
|
{{- $.Scratch.Add "pages" (slice $pagePath) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- template "treeSections" (dict "$" $ "path" (printf `%s/%s` $path $fileName)) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|