]> juplo.de Git - website/commitdiff
WIP:layout:menu
authorKai Moritz <kai@juplo.de>
Sat, 13 Dec 2025 16:27:44 +0000 (17:27 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 14 Dec 2025 16:26:41 +0000 (17:26 +0100)
layouts/_partials/menu.html

index 300fae9c5f686211858c95cd14a2dd5a2d86b355..396c34043817e4d5f0d6f64284625cb581d28e02 100644 (file)
@@ -20,7 +20,7 @@
   </h2>
   {{- with index site.Menus $menuID }}
   <ul id="submenu" class="s selected">
-    {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
+    {{- partial "inline/menu/tree.html" (dict "pages" $page.Site.MainSections "current $page) }}
   </ul>
   {{- end }}
 
   </ul>
   <hr class="n"/>
 </nav>
-{{- define "_partials/inline/menu/walk.html" }}
-  {{- $page := .page }}
-  {{- range .menuEntries }}
-    {{- $attrs := dict "href" .URL }}
-    {{- if $page.IsMenuCurrent .Menu . }}
-      {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
-    {{- else if $page.HasMenuCurrent .Menu .}}
-      {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
-    {{- end }}
-    {{- $name := .Name }}
-    {{- with .Identifier }}
-      {{- with T . }}
-        {{- $name = . }}
-      {{- end }}
-    {{- end }}
-    <li class="s sub"><!-- sub? off? -->
-      <a
-        {{- range $k, $v := $attrs }}
-          {{- with $v }}
-            {{- printf " %s=%q" $k $v | safeHTMLAttr }}
-          {{- end }}
-        {{- end -}}
-      >{{ $name }}</a>
-      {{- with .Children }}
-        <ul class="submenu"><!-- selected? -->
-          {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
-        </ul>
+{{- define "_partials/inline/menu/tree.html" }}
+{{- $current := .current -}}
+{{- $pages := .pages -}}
+
+<ul class="page-tree">
+  {{- range $pages }}
+    {{- $isCurrent := $current.IsCurrent . -}}
+    {{- $isAncestor := $current.IsAncestor . -}}
+
+    <li
+      class="
+        page-tree__item
+        {{ if $isCurrent }} is-current{{ end }}
+        {{ if $isAncestor }} is-ancestor{{ end }}
+      "
+    >
+      <a href="{{ .RelPermalink }}">
+        {{ .Title }}
+      </a>
+
+      {{- if .Pages }}
+        {{- partial "tree.html" (dict
+            "pages" .Pages
+            "current" $current
+        ) }}
       {{- end }}
     </li>
   {{- end }}
+</ul>
 {{- end }}