47 lines
1 KiB
HTML
47 lines
1 KiB
HTML
{{ template "structure-menu" (dict "currentLevel" $.Site "currentPage" .Page "level" 0 ) }}
|
|
|
|
|
|
{{ define "structure-menu" }}
|
|
{{ $level := .level }}
|
|
{{ $currentLevel := .currentLevel }}
|
|
{{ $currentPage := .currentPage }}
|
|
{{ $children := .currentLevel.Sections }}
|
|
|
|
{{ if $currentLevel.Pages }}
|
|
{{ range $currentLevel.Pages }}
|
|
{{ if not (eq 0 $level) }}
|
|
{{ $children = $children | append . }}
|
|
{{ else }}
|
|
{{ if and ( eq .Section "" ) ( not .IsHome ) }}
|
|
{{ $children = $children | append . }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
|
|
{{ $url := "#" }}
|
|
{{ if gt $level 0 }}
|
|
{{ $url = $currentLevel.Permalink }}
|
|
{{ else }}
|
|
{{ $url = $currentLevel.BaseURL }}
|
|
{{ end }}
|
|
|
|
<a href="{{ $url }}">{{ $currentLevel.Title }}</a>
|
|
|
|
{{ if $children }}
|
|
<ol>
|
|
{{ range $children }}
|
|
<li>
|
|
{{ if .IsNode }}
|
|
{{ template "structure-menu" (dict "currentLevel" . "currentPage" $currentPage "level" (add 1 $level)) }}
|
|
{{ else }}
|
|
* <a href="{{ .Permalink }}">{{ .Title }}</a>
|
|
{{ end }}
|
|
</li>
|
|
{{ end }}
|
|
</ol>
|
|
{{ end }}
|
|
|
|
{{ end }}
|