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

index e2bbc52bb5c5d50478108b0adf0a2f0b0df23865..c3e7bf60f928d5165086c7d862c791149f04f2d3 100644 (file)
     {{- end }}
   </ul>
   <h2 class="nav submenu">
-    <span class="s">Submenu for section</span>
-    <a class="s selected" href="../projects.html" th:href="@{${section}}" th:text="${_titles.get(section)}">Projects</a>
+    <a class="s selected" href="{{ site.Home.RelPermalink }}">Home</a>
   </h2>
-  {{- with index site.Menus $menuID }}
-  <ul id="submenu" class="s selected">
-    {{- partial "inline/menu/tree.html" (dict "pages" $page.Site.Sections "current" $page) }}
-  </ul>
-  {{- end }}
+  <ul class="submenu selected">
+  {{- partial "inline/menu/tree.html" (dict "pages" $page.Site.Sections "current" $page) }}
   {{- define "_partials/inline/menu/tree.html" }}
   {{- $current := .current -}}
   {{- $pages := .pages -}}
-  {{- $isCurrent := eq . $current -}}
-  {{- $isAncestor := $current.IsDescendant . -}}
-  <ul class="submenu">
     {{- range $pages }}
-  
+      {{- $isCurrent := eq . $current -}}
+      {{- $isAncestor := $current.IsDescendant . -}}
       <li
-        class="
-          page-tree__item
-          {{ if $isCurrent }} is-current{{ end }}
-          {{ if $isAncestor }} is-ancestor{{ end }}
-        "
-      >
+        class="s{{ if or $current.Pages $current.Sections}} sub{{ end }}">
+      <!--
+        th:with="
+            child=${pos == len},
+            hidden=${!child && _canonical.get(crumbs.get(pos)) == entry},
+            entry=${hidden?crumbs.get(pos):entry},
+            selected=${(child and crumbs.get(pos-1) + '?about' == entry) or (!child and (crumbs.get(pos) == entry or hidden))},
+            leaf=${pos >= (len - 1) and not selected},
+            sibling=${pos + 1 == len and (_childs.get(uri) == null or uri == parent)},
+            childs=${entry == parent ? null : _childs.get(entry)}
+            "
+        class="s sub"
+        th:class="'s' + (${childs} ? ' sub' : '') + (${selected or sibling or child} ? '' : ' off')"
+      -->
         <a href="{{ .RelPermalink }}">
           {{ .Title }}
         </a>
-  
+  <ul class="submenu{{ if (or $isCurrent $isAncestor) }} selected{{ end }}">
         {{- if .Pages }}
           {{- partial "inline/menu/tree.html" (dict
               "pages" .Pages
               "current" $current
           ) }}
         {{- end }}
+  </ul>
       </li>
-  
     {{- end }}
-  </ul>
   {{- end }}
+  </ul>
 
   <ul th:include="${submenu}?:_"
       th:with="