diff options
author | Cengiz Gunay <cengique@users.sf.net> | 2022-02-06 00:33:05 +0300 |
---|---|---|
committer | Cengiz Gunay <cengique@users.sf.net> | 2022-02-06 00:33:05 +0300 |
commit | 16b83dbd1ee86be37c1cea8271b677e2d0e7b126 (patch) | |
tree | 57fd5822281292b68ccdda0fbd9d71c615c783e4 | |
parent | 55fe049fd24d8c0fba7e65a60ea06cb59d73fd3b (diff) |
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 -}} + |