diff options
author | Yosuke Mizuno <thingsym@gmail.com> | 2022-07-06 13:00:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-06 13:00:20 +0300 |
commit | f2816255e4d518e6bd89f8b08f71d3bd9961c4fb (patch) | |
tree | 2cf2d8cd21eff29471e53c6387c6b3ebee33396b | |
parent | 4c28114f1d600868091a1ad6213298b159efc48d (diff) | |
parent | 16b83dbd1ee86be37c1cea8271b677e2d0e7b126 (diff) |
Merge pull request #48 from cengique/master
pre and post elements added to menu items
-rw-r--r-- | layouts/partials/global-menu.html | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/layouts/partials/global-menu.html b/layouts/partials/global-menu.html index bd2dabd..132b26f 100644 --- a/layouts/partials/global-menu.html +++ b/layouts/partials/global-menu.html @@ -5,18 +5,32 @@ <ul> {{- range .Site.Menus.main.ByWeight -}} {{ if .HasChildren -}} -<li class="parent{{ if $currentPage.HasMenuCurrent "main" . }} active{{ end }}"><a href="{{ .URL }}">{{- .Name -}} <i class="fas fa-angle-right"></i></a> +<li class="parent{{ if $currentPage.HasMenuCurrent "main" . }} active{{ end }}">{{template "menu-item" dict "item" .}} <ul class="sub-menu"> {{ range .Children -}} -<li class="child{{ if $currentPage.HasMenuCurrent "main" . }} active{{ end }}"><a href="{{ .URL }}">{{ .Name }}</a></li> +<li class="child{{ if $currentPage.HasMenuCurrent "main" . }} active{{ end }}">{{template "menu-item" dict "item" .}}</li> {{ end -}} </ul> </li> {{- else }} -<li{{ if $currentPage.HasMenuCurrent "main" . }} class="active"{{ end }}><a href="{{ .URL }}">{{- .Name -}}</a></li> +<li{{ if $currentPage.HasMenuCurrent "main" . }} class="active"{{ end }}>{{template "menu-item" dict "item" .}}</li> {{- end -}} {{- end -}} </ul> </nav> </div> {{- end }} + +{{define "menu-item"}} +{{- with .item -}} +<a href="{{ .URL }}"> + {{- with .Pre -}}{{- . -}}{{- end -}} + {{- .Name -}} + {{- with .Post -}}{{- . -}}{{- end -}} + {{ if .HasChildren -}} + <i class="fas fa-angle-right"></i> + {{ end -}} +</a> +{{- end -}} +{{- end -}} + |