1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-12-19 00:52:19 +01:00

layouts/_default/baseof.html: Update navbar menu template

Uses the same code as the Hugo menu template example, which should be
more robust with nested menus.
This commit is contained in:
Alan Orth 2018-03-09 20:29:11 +02:00
parent 74b3b2bfd8
commit cbd7140e63
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -36,10 +36,10 @@
<div class="container"> <div class="container">
<nav class="nav blog-nav"> <nav class="nav blog-nav">
<a class="nav-link {{ if .IsHome }}active{{ end }}" href="{{ .Site.BaseURL | absLangURL }}">{{ i18n "home" }}</a> <a class="nav-link {{ if .IsHome }}active{{ end }}" href="{{ .Site.BaseURL | absLangURL }}">{{ i18n "home" }}</a>
{{- $currentURL := .URL | absLangURL -}} {{- $currentPage := . -}}
{{ range .Site.Menus.navbar }} {{ range .Site.Menus.navbar }}
{{ $menuURL := .URL | absLangURL }} {{ $menuURL := .URL | absLangURL }}
<a class="nav-link{{ if eq $menuURL $currentURL }} active{{ end }}" href="{{.URL | absURL }}">{{ .Name }}</a> <a class="nav-link{{ if or ($currentPage.IsMenuCurrent "navbar" .) ($currentPage.HasMenuCurrent "navbar" .) }} active{{end}}" href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a>
{{ end }} {{ end }}
</nav> </nav>
</div> </div>