2022-06-22 18:32:18 +00:00
|
|
|
{{- $context := .context }}
|
|
|
|
{{- $showhidden := .showhidden | default false }}
|
|
|
|
{{- if eq (printf "%T" $showhidden) "string" }}
|
|
|
|
{{- $showhidden = (eq $showhidden "true") }}
|
|
|
|
{{- end }}
|
|
|
|
{{- $style := .style | default "li" }}
|
|
|
|
{{- $depth := .depth | default 1 }}
|
|
|
|
{{- $withDescription := .description | default false }}
|
|
|
|
{{- if eq (printf "%T" $withDescription) "string" }}
|
|
|
|
{{- $withDescription = (eq $withDescription "true") }}
|
|
|
|
{{- end }}
|
|
|
|
{{- $sortTerm := .sort | lower }}
|
|
|
|
{{- $containerstyle := .containerstyle | default "ul" }}
|
|
|
|
{{- if( and (not (eq $style "li") ) (eq $containerstyle "ul" ) ) }}
|
|
|
|
{{- $containerstyle = "div" }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- with $context }}
|
|
|
|
{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }}
|
|
|
|
{{- $pages := .Page.Pages }}
|
|
|
|
{{- if .Page.IsHome }}
|
|
|
|
{{- $pages = .Page.Sections }}
|
|
|
|
{{- else if .Page.Sections}}
|
|
|
|
{{- $pages = (.Page.Pages | union .Page.Sections) }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
|
|
|
{{- $currentOrdersectionsby := $sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
|
|
|
{{- if eq $currentOrdersectionsby "weight" }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else if eq $currentOrdersectionsby "publishdate" }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else if eq $currentOrdersectionsby "date" }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else if eq $currentOrdersectionsby "length" }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- end }}
|
|
|
|
{{ (printf "</%s>" $containerstyle)|safeHTML }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- define "childs" }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{ $context := .context }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- range .menu }}
|
|
|
|
{{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
|
|
|
{{- if not $hidden }}
|
|
|
|
{{- if not .IsHome }}
|
|
|
|
{{- if hasPrefix $.style "h" }}
|
|
|
|
{{- $num := sub ( int (trim $.style "h") ) 1 }}
|
|
|
|
{{- $numn := add $num $.count }}
|
2022-11-11 12:44:23 +00:00
|
|
|
{{ (printf "<h%d>" $numn)|safeHTML }}<a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}">{{ .Title }}</a>{{ (printf "</h%d>" $numn)|safeHTML }}
|
2022-10-07 18:05:49 +00:00
|
|
|
{{- if $.description }}
|
|
|
|
{{- if .Description -}}
|
|
|
|
<p>{{ .Description }}</p>
|
|
|
|
{{- else -}}
|
|
|
|
<p>{{ .Summary }}</p>
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2022-06-22 18:32:18 +00:00
|
|
|
|
2022-10-07 18:05:49 +00:00
|
|
|
{{- else if eq $.style "li" }}
|
2022-11-11 12:44:23 +00:00
|
|
|
{{ (printf "<%s>" $.style)|safeHTML }}<a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}">{{ .Title }}</a>
|
2022-10-07 18:05:49 +00:00
|
|
|
{{- if $.description }}
|
|
|
|
{{- if .Description -}}
|
|
|
|
<p>{{ .Description }}</p>
|
|
|
|
{{- else -}}
|
|
|
|
<p>{{ .Summary }}</p>
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2022-06-22 18:32:18 +00:00
|
|
|
|
|
|
|
{{- else }}
|
2022-11-11 12:44:23 +00:00
|
|
|
{{ (printf "<%s>" $.style)|safeHTML }}<a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}">{{ .Title }}</a>{{ (printf "</%s>" $.style)|safeHTML }}
|
2022-10-07 18:05:49 +00:00
|
|
|
{{- if $.description }}
|
|
|
|
{{- if .Description -}}
|
2022-06-22 18:32:18 +00:00
|
|
|
<p>{{ .Description }}</p>
|
2022-10-07 18:05:49 +00:00
|
|
|
{{- else -}}
|
2022-06-22 18:32:18 +00:00
|
|
|
<p>{{ .Summary }}</p>
|
2022-10-07 18:05:49 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if lt $.count $.depth }}
|
|
|
|
|
|
|
|
{{- if eq $.style "li" }}
|
|
|
|
{{- (printf "<%s>" $.containerstyle)|safeHTML }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- $pages := .Page.Pages }}
|
|
|
|
{{- if .Page.IsHome }}
|
|
|
|
{{- $pages = .Page.Sections }}
|
|
|
|
{{- else if .Page.Sections}}
|
|
|
|
{{- $pages = (.Page.Pages | union .Page.Sections) }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
|
|
|
{{- $currentOrdersectionsby := $.sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
|
|
|
{{- if eq $currentOrdersectionsby "weight" }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else if eq $.currentOrdersectionsby "publishdate" }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else if eq $.currentOrdersectionsby "date" }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else if eq $.currentOrdersectionsby "length" }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- else }}
|
2022-11-08 14:41:49 +00:00
|
|
|
{{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- if eq $.style "li" }}
|
|
|
|
{{- (printf "</%s>" $.containerstyle)|safeHTML }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2022-10-07 18:05:49 +00:00
|
|
|
|
|
|
|
{{- if not .IsHome }}
|
|
|
|
{{- if eq $.style "li" }}
|
|
|
|
{{- (printf "</%s>" $.style)|safeHTML -}}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|