theme-blog-ewen/layouts/partials/section-menu2.html
2020-04-12 10:16:04 +02:00

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 }}