Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

If a menu entry has a page, make it a link even for nested menus. #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions layouts/partials/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@
{{ $.Scratch.Set "currentMenuEntry" . }}
<li>
{{ if .HasChildren }}

{{ $currentMenuEntry := $.Scratch.Get "currentMenuEntry" }}
{{ $.Scratch.Set "foundIndex" false }}
{{ range where $.Site.Pages ".URLPath.URL" "==" $currentMenuEntry.URL }}
{{ $.Scratch.Set "foundIndex" true }}
{{ end }}

{{ if $.Scratch.Get "foundIndex" }}
<span class="parent_section">{{ partial "nav_link" $currentNode }}</span>
{{ else }}
<span class="section">{{ .Name | title }}</span>
{{ end }}
<ul>
{{ range .Children }}
{{ $.Scratch.Set "currentMenuEntry" . }}
Expand Down