Add "main" menu to the site header

Based on "Menu Templates" (https://gohugo.io/templates/menu-templates/)
pull/1/head
Kevin C. Coram 2019-11-19 19:29:08 -05:00
parent bdbe3f9d78
commit f2129ca33a
Signed by: kevin
GPG Key ID: 0342351B3D61AD35
1 changed files with 29 additions and 0 deletions

View File

@ -1,2 +1,31 @@
<header> <header>
<nav>
<ul>
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
<a href="#">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
</li>
<ul class="sub-menu">
{{ range .Children }}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
<a href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
{{ else }}
<li>
<a href="{{ .URL }}">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
</li>
{{ end }}
{{ end }}
</ul>
</nav>
</header> </header>