feat: derive sidebar from content

This commit is contained in:
2026-06-21 18:01:31 +00:00
parent b9b78db633
commit f8af9035e8
6 changed files with 36 additions and 61 deletions
+29 -25
View File
@@ -1,29 +1,33 @@
{{- range .ByWeight -}}
<div class="flex flex-col">
<a class="flex items-center {{ if .HasChildren }}text-on-surface{{ else }}text-on-surface-variant{{ end }} hover:text-primary transition-colors py-1 text-left w-full group" href="{{ .URL }}">
<span class="material-symbols-outlined text-[16px] mr-1 text-on-surface-variant group-hover:text-primary">{{ if .HasChildren }}expand_more{{ else }}chevron_right{{ end }}</span>
{{ .Name }}
</a>
{{- with .Children -}}
<div class="ml-6 flex flex-col gap-1 text-on-surface-variant text-label-sm tree-item mt-1 mb-2">
{{- range .ByWeight -}}
{{- if .HasChildren -}}
<div class="flex flex-col">
<a class="flex items-center hover:text-on-surface transition-colors py-0.5" href="{{ .URL }}">
<span class="material-symbols-outlined text-[14px] mr-1 text-on-surface-variant">expand_more</span>
{{ .Name }}
</a>
<div class="ml-5 flex flex-col gap-1 text-on-surface-variant text-label-sm tree-item mt-1 italic">
{{ range .Children.ByWeight }}
<a class="hover:text-on-surface transition-colors py-0.5" href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
</div>
</div>
{{- else -}}
<a class="hover:text-on-surface transition-colors py-0.5 italic" href="{{ .URL }}">{{ .Name }}</a>
{{- end -}}
{{- range .nodes.ByWeight -}}
{{- if eq $.level 0 -}}
<div class="flex flex-col">
<a class="flex items-center {{ if .IsSection }}text-on-surface{{ else }}text-on-surface-variant{{ end }} hover:text-primary transition-colors py-1 text-left w-full group" href="{{ .RelPermalink }}">
<span class="material-symbols-outlined text-[16px] mr-1 text-on-surface-variant group-hover:text-primary">{{ if .IsSection }}expand_more{{ else }}chevron_right{{ end }}</span>
{{ .LinkTitle }}
</a>
{{- if .IsSection -}}
{{- with .Pages.ByWeight -}}
<div class="ml-6 flex flex-col gap-1 text-on-surface-variant text-label-sm tree-item mt-1 mb-2">
{{ partial "menu-tree.html" (dict "nodes" . "level" (add $.level 1)) }}
</div>
{{- end -}}
{{- end -}}
</div>
{{- else -}}
{{- if .IsSection -}}
<div class="flex flex-col">
<a class="flex items-center hover:text-on-surface transition-colors py-0.5" href="{{ .RelPermalink }}">
<span class="material-symbols-outlined text-[14px] mr-1 text-on-surface-variant">expand_more</span>
{{ .LinkTitle }}
</a>
{{- with .Pages.ByWeight -}}
<div class="ml-5 flex flex-col gap-1 text-on-surface-variant text-label-sm tree-item mt-1 italic">
{{ partial "menu-tree.html" (dict "nodes" . "level" (add $.level 1)) }}
</div>
{{- end -}}
</div>
{{- else -}}
<a class="hover:text-on-surface transition-colors py-0.5 italic" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{- end -}}
</div>
{{- end -}}
{{- end -}}
@@ -9,8 +9,8 @@
</button>
<nav class="flex flex-col gap-1 text-sm" aria-label="Primary">
{{ with site.Menus.main }}
{{ partial "menu-tree.html" . }}
{{ with site.Sections }}
{{ partial "menu-tree.html" (dict "nodes" . "level" 0) }}
{{ end }}
</nav>