theme-blog-ewen/layouts/partials/section-menu2.html

47 lines
1 KiB
HTML
Raw Permalink Normal View History

2023-12-15 16:26:57 +00:00
{{ 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 }}