feat(i18n): Allow localizing menus with i18n dynamically

This commit is contained in:
CcydtN 2023-01-29 04:07:04 +08:00
parent 4272da7ee4
commit 2bc605480e

View File

@ -62,7 +62,7 @@
{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
{{ $active := or (eq $currentPage.Title .Name) (or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .)) }} {{ $active := or (eq $currentPage.Title .Name) (or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .)) }}
<li {{ if $active }} class='current' {{ end }}> <li {{ if $active }} class='current' {{ end }}>
<a href='{{ .URL }}' {{ if eq .Params.newTab true }}target="_blank"{{ end }}> <a href='{{ .URL | absLangURL }}' {{ if eq .Params.newTab true }}target="_blank"{{ end }}>
{{ $icon := default .Pre .Params.Icon }} {{ $icon := default .Pre .Params.Icon }}
{{ if .Pre }} {{ if .Pre }}
{{ warnf "Menu item [%s] is using [pre] field to set icon, please use [params.icon] instead.\nMore information: https://docs.stack.jimmycai.com/configuration/custom-menu.html" .URL }} {{ warnf "Menu item [%s] is using [pre] field to set icon, please use [params.icon] instead.\nMore information: https://docs.stack.jimmycai.com/configuration/custom-menu.html" .URL }}
@ -70,7 +70,7 @@
{{ with $icon }} {{ with $icon }}
{{ partial "helper/icon" . }} {{ partial "helper/icon" . }}
{{ end }} {{ end }}
<span>{{- .Name -}}</span> <span>{{ i18n .Identifier | default .Name}}</span>
</a> </a>
</li> </li>
{{ end }} {{ end }}