add active flag if current title matches identifier

master
Lars Hoogestraat 8 months ago
parent 2e3f38ccb4
commit 323c4f9fcf
  1. 2
      exampleSite/config.toml
  2. 1
      layouts/partials/footer.html
  3. 1
      layouts/partials/nav.html

@ -10,7 +10,7 @@ pygmentsCodefencesGuessSyntax = true
relativeURLs = false
[Params]
[params]
useSummary = true
description = 'An example description'

@ -3,6 +3,7 @@
{{ $current := . }}
{{ range .Site.Menus.footer.ByWeight }}
{{ $active := or ($current.IsMenuCurrent "footer" .) ($current.HasMenuCurrent "footer" .) }}
{{ $active = or $active (eq .Identifier $current.Title) }}
{{ $active = or $active (eq .Name $current.Title) }}
<li>

@ -4,6 +4,7 @@
{{ range .Site.Menus.nav }}
{{ $active := or ($current.IsMenuCurrent "nav" .) ($current.HasMenuCurrent "nav" .) }}
{{ $active = or $active (eq .Name $current.Title) }}
{{ $active = or $active (eq .Identifier $current.Title) }}
{{ $active = or $active (and (eq .Name "Articles") (eq $current.Section "posts")) }}
<li>
<a {{if $active}}class="active"{{end}} href="{{ .URL | relLangURL }}">{{ .Name }}</a>

Loading…
Cancel
Save