hugo-theme-learn icon indicating copy to clipboard operation
hugo-theme-learn copied to clipboard

Menu: only expand active hierarchy (fixes #195)

Open oldenboom opened this issue 5 years ago • 2 comments

Pull request @robhoes is on older version of theme and required some work. Reviewed those edits, then used master to redo the edits to prepare this pull request.

oldenboom avatar Dec 18 '19 21:12 oldenboom

Is there a specific reason why this hasn't been merged yet?

seekM avatar May 08 '20 10:05 seekM

@oldenboom the following diff fixes the conflicts in menu.html:

diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html
index 5583eda..c023003 100644
--- a/layouts/partials/menu.html
+++ b/layouts/partials/menu.html
@@ -99,18 +99,25 @@
  {{with .sect}}
   {{if and .IsSection (or (not .Params.hidden) $.showhidden)}}
     {{safeHTML .Params.head}}
+    {{ $isParent := or (.IsAncestor $currentNode) (.Params.alwaysopen) }}
+    {{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
     <li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item 
-        {{if .IsAncestor $currentNode }}parent{{end}}
+        {{if $isParent }}parent{{end}}
         {{if eq .File.UniqueID $currentFileUniqueID}}active{{end}}
-        {{if .Params.alwaysopen}}parent{{end}}
         ">
       <a href="{{.RelPermalink}}">
           {{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}}
+          {{ if and (ne $numberOfPages 0) (ne .Parent .Site.Home) }}
+            {{if $isParent }}
+              <i class="fas fa-caret-down"></i>
+            {{ else }}
+              <i class="fas fa-caret-right"></i>
+            {{ end }}
+          {{ end }}
           {{ if $showvisitedlinks}}
-            <i class="fas fa-check read-icon"></i>
+            <i class="fas fa-check"></i>
           {{ end }}
       </a>
-      {{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
       {{ if ne $numberOfPages 0 }}
         <ul>
           {{ $currentNode.Scratch.Set "pages" .Pages }}

root360-AndreasUlm avatar Jun 07 '20 16:06 root360-AndreasUlm