83 lines
4.7 KiB
HTML
83 lines
4.7 KiB
HTML
{{- define "print" -}}
|
|
{{- $currentPage := . -}}
|
|
{{- $renderPage := "" -}}
|
|
{{- $populateDict := dict -}}
|
|
{{- $renderPaths := slice -}}
|
|
{{- $pagePaths := slice -}}
|
|
{{- $nestedPagePaths := slice -}}
|
|
{{- range $printItem := .Params.print -}}
|
|
{{- range $renderItem := $printItem.loop -}}
|
|
{{- warnf "$renderItem: %s" $renderItem -}}
|
|
{{- if gt (len $pagePaths) 0 -}}
|
|
{{- range $nestedPage := $pagePaths -}}
|
|
{{- with $p := site.GetPage $nestedPage -}}
|
|
{{- $section := "" -}}
|
|
{{- $nestedPagePaths = $nestedPagePaths|append $nestedPage -}}
|
|
{{- with index $p.Params $renderItem -}}
|
|
{{- range $page := index $p.Params $renderItem -}}
|
|
{{- if hasPrefix $renderItem "_" -}}
|
|
{{- $section = partial "GetSingularSectionName.html" (strings.TrimPrefix "_" $renderItem) -}}
|
|
{{- else if strings.Contains $renderItem "_" -}}
|
|
{{- $section = partial "GetSingularSectionName.html" (index (last 1 (split $renderItem "_")) 0) -}}
|
|
{{- end -}}
|
|
{{- $nestedPagePaths = $nestedPagePaths|append (printf "/%s/%s" $section $page) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- if gt (len $nestedPagePaths) 0 -}}
|
|
{{- $pagePaths = $nestedPagePaths -}}
|
|
{{- $nestedPagePaths = slice -}}
|
|
{{- end -}}
|
|
{{- else if hasPrefix $renderItem "/" -}}
|
|
{{- with site.GetPage $renderItem -}}
|
|
{{- $renderPaths = $renderPaths|append $renderItem -}}
|
|
{{- $renderPage = . -}}
|
|
{{- end -}}
|
|
{{- else if $renderPage -}}
|
|
{{- $section := "" -}}
|
|
{{- range $page := index $renderPage.Params $renderItem -}}
|
|
{{- if hasPrefix $renderItem "_" -}}
|
|
{{- $section = partial "GetSingularSectionName.html" (strings.TrimPrefix "_" $renderItem) -}}
|
|
{{- else if strings.Contains $renderItem "_" -}}
|
|
{{- $section = partial "GetSingularSectionName.html" (index (last 1 (split $renderItem "_")) 0) -}}
|
|
{{- end -}}
|
|
{{- $pagePaths = $pagePaths|append (printf "/%s/%s" $section $page) -}}
|
|
{{- end -}}
|
|
{{- $renderPage = "" -}}
|
|
{{- else if isset $populateDict $renderItem -}}
|
|
{{- warnf "$populateDict: %s | $renderItem: %s" $populateDict $renderItem -}}
|
|
{{- range $pagePath := index (index $populateDict $renderItem) "pages" -}}
|
|
{{- $renderPaths = $renderPaths | append $pagePath -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- with $printItem.populate -}}
|
|
{{- range $popMap := . -}}
|
|
{{- range $popKey, $popValue := $popMap -}}
|
|
{{- $populatePagePaths := index (index $populateDict $popKey) "pages" | default slice -}}
|
|
{{- range $pagePath := (union $renderPaths $pagePaths) -}}
|
|
{{- with site.GetPage $pagePath -}}
|
|
{{- $section := "" -}}
|
|
{{- with $pages := index .Params $popValue -}}
|
|
{{- warnf "$popValue: %s" $popValue -}}
|
|
{{- if hasPrefix $popValue "_" -}}
|
|
{{- $section = partial "GetSingularSectionName.html" (strings.TrimPrefix "_" $popValue) -}}
|
|
{{- else if strings.Contains $popValue "_" -}}
|
|
{{- $section = partial "GetSingularSectionName.html" (index (last 1 (split $popValue "_")) 0) -}}
|
|
{{- end -}}
|
|
{{- range $page := $pages -}}
|
|
{{- $populatePagePaths = $populatePagePaths | append (printf "/%s/%s" $section $page) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- $populateDict = merge $populateDict (dict $popKey (dict "graph" $popValue "pages" $populatePagePaths)) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- $renderPaths = $renderPaths|append $pagePaths -}}
|
|
{{- $pagePaths = slice -}}
|
|
{{- end -}}
|
|
{{- printf "%#v" $renderPaths -}}
|
|
{{- end -}}
|