2024-04-14 11:31:13 +01:00
|
|
|
{{- $context := . -}}
|
|
|
|
|
|
|
|
{{- $pages := union .RegularPages .Sections -}}
|
|
|
|
{{- $pages = where $pages "Params.sidebar.exclude" "!=" true -}}
|
|
|
|
|
|
|
|
{{- $data := slice -}}
|
|
|
|
|
|
|
|
{{- range $pages.ByWeight -}}
|
|
|
|
{{ $structure := (partial "sidebar/section-walk" .) | unmarshal -}}
|
|
|
|
{{ $data = $data | append $structure -}}
|
|
|
|
{{ end -}}
|
|
|
|
|
|
|
|
{{- define "partials/sidebar/section-walk" -}}
|
|
|
|
{{- with . -}}
|
|
|
|
{
|
2024-04-30 23:02:36 +01:00
|
|
|
"title": "{{ partial "utils/title" . }}",
|
2024-04-14 11:31:13 +01:00
|
|
|
"link": "{{ .RelPermalink }}",
|
|
|
|
"toc": {{ partial "sidebar/section-page-toc" . }},
|
|
|
|
"open": {{ .Params.sidebar.open | default false }}
|
|
|
|
{{- if .IsSection }},
|
|
|
|
"items": [
|
|
|
|
{{ $pages := union .RegularPages .Sections -}}
|
|
|
|
{{ $pages = where $pages "Params.sidebar.exclude" "!=" true -}}
|
|
|
|
{{ range $index, $page := $pages.ByWeight -}}
|
|
|
|
{{ partial "sidebar/section-walk" . }}{{ if not (ge $index (sub (len $pages) 1)) }},{{ end -}}
|
|
|
|
{{ end -}}
|
|
|
|
]
|
|
|
|
{{ end -}}
|
|
|
|
}
|
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- define "partials/sidebar/section-page-toc" -}}
|
|
|
|
{{/* Get level 2 headings list used mainly for mobile navigation */}}
|
|
|
|
[
|
|
|
|
{{- with .Fragments.Headings -}}
|
|
|
|
{{/* Loop over level 1 headings */}}
|
|
|
|
{{- range . }}
|
|
|
|
{{- with .Headings }}
|
|
|
|
{{ $headings := . }}
|
|
|
|
{{- range $index, $heading := $headings }}
|
|
|
|
{{ $heading.Title | jsonify (dict "noHTMLEscape" true) }}
|
|
|
|
{{- if not (ge $index (sub (len $headings) 1)) }},{{ end -}}
|
|
|
|
{{ end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{ end -}}
|
|
|
|
{{- end -}}
|
|
|
|
]
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{ return ($data | jsonify (dict "noHTMLEscape" true)) }}
|