]> juplo.de Git - website/commitdiff
WIP:layout:menu
authorKai Moritz <kai@juplo.de>
Sun, 14 Dec 2025 16:01:05 +0000 (17:01 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 14 Dec 2025 17:45:14 +0000 (18:45 +0100)
layouts/_partials/menu.html

index 2b72d7502c4c4db5b5ebdb593b02715b5b954de2..bede5bb30be8b2d748ae799f8f0407c4100cadef 100644 (file)
     <a class="s selected" href="{{ site.Home.RelPermalink }}">Home</a>
   </h2>
   <ul id="submenu" class="submenu selected">
-  {{- partial "inline/menu/tree.html" (dict "pages" $page.Site.Sections "page" $page "parent" site.Home) }}
+  {{- partial "inline/menu/tree.html" (dict "pages" $page.Site.Sections "page" $page) }}
   {{- define "_partials/inline/menu/tree.html" }}
     {{- $page := .page -}}
-    {{- $parent := .parent -}}
     {{- range .pages -}}
+    {{- $parent := index .Ancestors 0 -}}
     {{- $isCurrent := eq . $page -}}
     {{- $isAncestor := $page.IsDescendant . -}}
-    <li class="s{{ if or .Pages .Sections}} sub{{ end }}{{ if not (or (eq $page .) ($page.IsDescendant .))}} off{{ end }}">
+    {{- $isChild := $parent.Eq $page }}
+    {{- $isSibling := $parent.Eq (index $page.Ancestors 0) }}
+    <li class="s{{ if or .Pages .Sections}} sub{{ end }}{{ if not (or $isAncestor $isSibling $isChild) }} off{{ end }}">
       <!--
         th:with="
             child=${pos == len},
       <a  href="{{ .RelPermalink }}"
           class="s {{ if (or $isCurrent $isAncestor) }} selected{{ end }}"
           >{{ .Title }}</a>
+      <!-- .: {{ .Path }} -->
+      <!-- $parent: {{ $parent.Path }} -->
+      <!-- $page: {{ $page.Path }} -->
+      <!-- $isCurrent: {{ $isCurrent }} -->
+      <!-- $isAncestor: {{ $isAncestor }} -->
+      <!-- $isSibling: {{ $isSibling }} -->
+      <!-- $isChild: {{ $isChild }} -->
+      <!-- .Eq $page: {{ .Eq $page }} -->
+      <!-- .IsAncestor $page: {{ .IsAncestor $page }} -->
+      <!-- .IsDescendant $page: {{ .IsDescendant $page }} -->
       {{ if or .Pages .Sections }}
       <ul class="s{{ if (or $isCurrent $isAncestor) }} active{{ end }}">
         {{- if .Pages }}
           {{- partial "inline/menu/tree.html" (dict
               "pages" .Pages
               "page" $page
-              "parent" .
           ) }}
         {{- end }}
       </ul>