Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/devcows/hugo-universal-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo Guerrero Ibarra <wolf.fox1985@gmail.com>2021-08-13 01:28:33 +0300
committerGitHub <noreply@github.com>2021-08-13 01:28:33 +0300
commit22efcc0cc397ebdaa7d4f3543608b14316a88698 (patch)
tree405251be9306f86ee9e327cd2eafa1d4a8f72377
parentcabdeac091016efa9cf0ec9b2483c0eacff48989 (diff)
Fixed menu highlight. (#313)1.2.2
Co-authored-by: Guillermo Guerrero Ibarra <guillermo.guerrero@deliveroo.co.uk>
-rw-r--r--layouts/partials/nav.html19
1 files changed, 17 insertions, 2 deletions
diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html
index 3b98707..8142469 100644
--- a/layouts/partials/nav.html
+++ b/layouts/partials/nav.html
@@ -19,12 +19,27 @@
<div class="navbar-collapse collapse" id="navigation">
<ul class="nav navbar-nav navbar-right">
{{ $current := . }}
- {{ $topLevel := replace .URL "/" "" }}
+
{{ range .Site.Menus.main.ByWeight }}
+ {{ $topLevel := replace .URL "/" "" }}
{{ $active := "" }}
- {{ if eq $current.RelPermalink .URL | or (eq $current.Type $topLevel) | or (and (eq (default (trim .URL "/") .Identifier) "blog") (in (slice "taxonomy" "taxonomyTerm") $current.Kind)) }}
+
+ {{ if eq $current.RelPermalink .URL }}
{{ $active = "active" }}
{{ end }}
+
+ {{ if eq $current.Type $topLevel }}
+ {{ $active = "active" }}
+ {{ end }}
+
+ {{ if and (or (eq $current.URL .URL) (eq "term" $current.Kind)) (in (slice "page" "term") $current.Kind) }}
+ {{ range (split .URL "/") }}
+ {{ if eq "blog" . }}
+ {{ $active = "active" }}
+ {{ end }}
+ {{ end }}
+ {{ end }}
+
{{ if .HasChildren }}
<!-- Check if the first child marks a menu section identifier -->
{{ $hasSections := (hasPrefix (index .Children 0).Identifier "section.") }}