Main menu: add pre/post properties support

This commit is contained in:
vimux 2019-11-10 00:28:44 -05:00
parent 6204d3ef0d
commit f184b72d8d
No known key found for this signature in database
GPG key ID: 5A34FDC4EE832E34

View file

@ -11,9 +11,16 @@
<ul id="menu" class="main-nav__list{{ if eq .Site.Params.mainMenuAlignment "right" }} main-nav__list--right{{ end }}"> <ul id="menu" class="main-nav__list{{ if eq .Site.Params.mainMenuAlignment "right" }} main-nav__list--right{{ end }}">
{{- $currentNode := . }} {{- $currentNode := . }}
{{- range sort .Site.Menus.main }} {{- range sort .Site.Menus.main }}
{{- if .Name }} {{- $current := (or ($currentNode.IsMenuCurrent "main" .) ($currentNode.HasMenuCurrent "main" .)) }}
<li class="main-nav__item{{ if or ($currentNode.IsMenuCurrent "main" .) ($currentNode.HasMenuCurrent "main" .) }} main-nav__item--active{{ end }}">{{ if or ($currentNode.IsMenuCurrent "main" .) ($currentNode.HasMenuCurrent "main" .) }}{{ .Name }}{{ else }}<a class="main-nav__link" href="{{ .URL }}">{{ .Name }}</a>{{ end }}</li> {{- if .Name }}
{{- end }} <li class="main-nav__item{{ if $current }} main-nav__item--active{{ end }}">
{{ if not $current }}<a class="main-nav__link" href="{{ .URL }}">{{ end }}
{{ .Pre }}
<span class="main-nav__text">{{ .Name }}</span>
{{ .Post }}
{{ if not $current }}</a>{{ end }}
</li>
{{- end }}
{{- end }} {{- end }}
</ul> </ul>
</nav> </nav>