diff options
author | Guillermo Guerrero Ibarra <guillermo.guerrero@deliveroo.co.uk> | 2021-08-05 10:10:54 +0300 |
---|---|---|
committer | Guillermo Guerrero Ibarra <guillermo.guerrero@deliveroo.co.uk> | 2021-08-05 10:10:54 +0300 |
commit | 4cad28689f6312d89e8ba6c0dd987e56bfee1f50 (patch) | |
tree | 03093a1a3667ac51d607c4373d2198c70f25342d | |
parent | b7e0cabee56afe2bb258e54b613d17b12a990557 (diff) |
active before if.
-rw-r--r-- | layouts/partials/nav.html | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index f1f2b89..3b98707 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -21,10 +21,14 @@ {{ $current := . }} {{ $topLevel := replace .URL "/" "" }} {{ range .Site.Menus.main.ByWeight }} + {{ $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)) }} + {{ $active = "active" }} + {{ end }} {{ if .HasChildren }} <!-- Check if the first child marks a menu section identifier --> {{ $hasSections := (hasPrefix (index .Children 0).Identifier "section.") }} - <li class="dropdown{{ if $hasSections }} use-yamm yamm-fw{{end}} {{ if eq $current.RelPermalink .URL | or (eq $current.Type $topLevel) | or (and (eq (default (trim .URL "/") .Identifier) "blog") (in (slice "taxonomy" "taxonomyTerm") $current.Kind)) }} active{{ end }}"> + <li class="dropdown{{ if $hasSections }} use-yamm yamm-fw{{end}} {{ $active }}"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ .Name }} <span class="caret"></span></a> {{ if $hasSections }} <ul class="dropdown-menu"> @@ -111,7 +115,7 @@ {{ end }} </li> {{ else }} - <li class="dropdown {{ if eq $current.RelPermalink .URL | or (eq $current.Type $topLevel) | or (and (eq (default (trim .URL "/") .Identifier) "blog") (in (slice "taxonomy" "taxonomyTerm") $current.Kind)) }} active{{ end }}"> + <li class="dropdown {{ $active }}"> <a href="{{ .URL }}">{{ .Name }}</a> </li> {{ end }} |