fix active navbar tab

This commit is contained in:
a 2021-10-17 23:03:36 -05:00
parent 1bb99acfe6
commit 56f1f8c12f
2 changed files with 10 additions and 7 deletions

View file

@ -12,14 +12,14 @@ category = "category"
[menu] [menu]
[[menu.main]] [[menu.main]]
identifier = "home" identifier = ""
pre = "<i class='fa fa-home' aria-hidden='true'></i>" pre = "<i class='fa fa-home' aria-hidden='true'></i>"
name = "Home" name = "Home"
url = "/" url = "/"
weight = 10 weight = 10
[[menu.main]] [[menu.main]]
identifier = "experience" identifier = "work"
pre = "<i class='fa fa-briefcase' aria-hidden='true'></i>" pre = "<i class='fa fa-briefcase' aria-hidden='true'></i>"
name = "Work" name = "Work"
url = "/work/" url = "/work/"

View file

@ -6,16 +6,19 @@
</a> </a>
<nav class="site-nav"> <nav class="site-nav">
<ul> <ul>
{{- $currentPage := . -}} {{ $currentPage := . }}
{{ range .Site.Menus.main -}} {{ range .Site.Menus.main }}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}"> <li class='
{{ if or ($currentPage.IsMenuCurrent "main" .) (eq $currentPage.Section .Identifier) }}
active
{{ end }}'>
<a href="{{ .URL | absLangURL }}"> <a href="{{ .URL | absLangURL }}">
{{ .Pre }} {{ .Pre }}
<span>{{ .Name }}</span> <span>{{ .Name }}</span>
{{ .Post }} {{ .Post }}
</a> </a>
</li> </li>
{{- end }} {{ end }}
</ul> </ul>
{{ partial "i18nlist.html" . }} {{ partial "i18nlist.html" . }}
</nav> </nav>