Files
hugo-starless/themes/starless/layouts/partials/explorer-tree.html

35 lines
1.5 KiB
HTML

{{- range .nodes.ByWeight -}}
{{- $isCurrent := eq .RelPermalink $.currentPage.RelPermalink -}}
{{- if eq $.level 0 -}}
<div class="tree-node">
<a class="tree-link{{ if .IsSection }} tree-link--section{{ end }}{{ if $isCurrent }} tree-link--current{{ end }}" href="{{ .RelPermalink }}">
<span class="material-symbols-outlined tree-icon">{{ if .IsSection }}expand_more{{ else }}chevron_right{{ end }}</span>
{{ .LinkTitle }}
</a>
{{- if .IsSection -}}
{{- with .Pages.ByWeight -}}
<div class="tree-children">
{{ partial "explorer-tree.html" (dict "nodes" . "level" (add $.level 1) "currentPage" $.currentPage) }}
</div>
{{- end -}}
{{- end -}}
</div>
{{- else -}}
{{- if .IsSection -}}
<div class="tree-node">
<a class="tree-link tree-link--nested{{ if $isCurrent }} tree-link--current{{ end }}" href="{{ .RelPermalink }}">
<span class="material-symbols-outlined tree-icon tree-icon--small">expand_more</span>
{{ .LinkTitle }}
</a>
{{- with .Pages.ByWeight -}}
<div class="tree-children tree-children--nested">
{{ partial "explorer-tree.html" (dict "nodes" . "level" (add $.level 1) "currentPage" $.currentPage) }}
</div>
{{- end -}}
</div>
{{- else -}}
<a class="tree-link tree-link--leaf{{ if $isCurrent }} tree-link--current{{ end }}" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{- end -}}
{{- end -}}
{{- end -}}