feat(menu): add menu pre

This commit is contained in:
Dillon 2020-02-04 02:19:05 +08:00
parent 097473ef2a
commit 8cd7e8d672
3 changed files with 7 additions and 3 deletions

View file

@ -97,7 +97,9 @@ dateFormatToUse = "2006-01-02"
[[menu.main]]
identifier = "zh"
name = '<i class="fas fa-language fa-fw" title="简体中文"></i>'
pre = '<i class="fas fa-language fa-fw"></i>'
name = ""
title = "简体中文"
url = "https://hugo-loveit-zh.netlify.com"
weight = 5

View file

@ -97,7 +97,9 @@ dateFormatToUse = "2006-01-02"
[[menu.main]]
identifier = "en"
name = '<i class="fas fa-language fa-fw" title="English"></i>'
pre = '<i class="fas fa-language fa-fw"></i>'
name = ""
title = "English"
url = "https://hugo-loveit-en.netlify.com"
weight = 5

View file

@ -10,7 +10,7 @@
{{- $currentPage := . }}
{{- range .Site.Menus.main -}}
<a class="menu-item{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) | or (eq $currentPage.RelPermalink .URL) }} active{{ end }}" href="{{ .URL | absLangURL }}" title="{{ .Title }}">
{{- .Name | safeHTML -}}
{{- .Pre | safeHTML }}{{ .Name -}}
</a>
{{- end -}}
<a href="javascript:void(0);" class="theme-switch"><i class="fas fa-adjust fa-rotate-180 fa-fw" title="{{ T "switchTheme" }}"></i></a>