refactor(menu): use .Params.icon to configure menu item icon (#400)

This commit is contained in:
Jimmy Cai 2021-10-23 09:18:44 +02:00 committed by GitHub
parent a822411a03
commit 7c59ac7713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 5 deletions

View File

@ -174,10 +174,10 @@ menu:
name: Home name: Home
url: / url: /
weight: -100 weight: -100
pre: home
params: params:
### For demonstration purpose, the home link will be open in a new tab ### For demonstration purpose, the home link will be open in a new tab
newTab: true newTab: true
icon: home
related: related:
includeNewer: true includeNewer: true

View File

@ -11,7 +11,8 @@ lastmod: '2020-10-09'
menu: menu:
main: main:
weight: -90 weight: -90
pre: user params:
icon: user
--- ---
Written in Go, Hugo is an open source static site generator available under the [Apache Licence 2.0.](https://github.com/gohugoio/hugo/blob/master/LICENSE) Hugo supports TOML, YAML and JSON data file types, Markdown and HTML content files and uses shortcodes to add rich content. Other notable features are taxonomies, multilingual mode, image processing, custom output formats, HTML/CSS/JS minification and support for Sass SCSS workflows. Written in Go, Hugo is an open source static site generator available under the [Apache Licence 2.0.](https://github.com/gohugoio/hugo/blob/master/LICENSE) Hugo supports TOML, YAML and JSON data file types, Markdown and HTML content files and uses shortcodes to add rich content. Other notable features are taxonomies, multilingual mode, image processing, custom output formats, HTML/CSS/JS minification and support for Sass SCSS workflows.

View File

@ -6,5 +6,6 @@ slug: "archives"
menu: menu:
main: main:
weight: -70 weight: -70
pre: archives params:
icon: archives
--- ---

View File

@ -8,5 +8,6 @@ outputs:
menu: menu:
main: main:
weight: -60 weight: -60
pre: search params:
icon: search
--- ---

View File

@ -40,8 +40,12 @@
<li {{ if $active }} class='current' {{ end }}> <li {{ if $active }} class='current' {{ end }}>
<a href='{{ .URL | relLangURL }}' {{ if eq .Params.newTab true }}target="_blank"{{ end }}> <a href='{{ .URL | relLangURL }}' {{ if eq .Params.newTab true }}target="_blank"{{ end }}>
{{ $icon := default .Pre .Params.Icon }}
{{ if .Pre }} {{ if .Pre }}
{{ partial "helper/icon" .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 }}
{{ end }}
{{ with $icon }}
{{ partial "helper/icon" . }}
{{ end }} {{ end }}
<span>{{- .Name -}}</span> <span>{{- .Name -}}</span>
</a> </a>