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,8 +11,15 @@
<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 }}
{{- $current := (or ($currentNode.IsMenuCurrent "main" .) ($currentNode.HasMenuCurrent "main" .)) }}
{{- if .Name }} {{- if .Name }}
<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> <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 }} {{- end }}
</ul> </ul>