mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-27 04:03:48 +01:00
refactor(menu): use .Params.icon to configure menu item icon (#400)
This commit is contained in:
parent
a822411a03
commit
7c59ac7713
5 changed files with 12 additions and 5 deletions
|
@ -174,10 +174,10 @@ menu:
|
|||
name: Home
|
||||
url: /
|
||||
weight: -100
|
||||
pre: home
|
||||
params:
|
||||
### For demonstration purpose, the home link will be open in a new tab
|
||||
newTab: true
|
||||
icon: home
|
||||
|
||||
related:
|
||||
includeNewer: true
|
||||
|
|
|
@ -11,7 +11,8 @@ lastmod: '2020-10-09'
|
|||
menu:
|
||||
main:
|
||||
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.
|
||||
|
|
|
@ -6,5 +6,6 @@ slug: "archives"
|
|||
menu:
|
||||
main:
|
||||
weight: -70
|
||||
pre: archives
|
||||
params:
|
||||
icon: archives
|
||||
---
|
||||
|
|
|
@ -8,5 +8,6 @@ outputs:
|
|||
menu:
|
||||
main:
|
||||
weight: -60
|
||||
pre: search
|
||||
params:
|
||||
icon: search
|
||||
---
|
|
@ -40,8 +40,12 @@
|
|||
|
||||
<li {{ if $active }} class='current' {{ end }}>
|
||||
<a href='{{ .URL | relLangURL }}' {{ if eq .Params.newTab true }}target="_blank"{{ end }}>
|
||||
{{ $icon := default .Pre .Params.Icon }}
|
||||
{{ 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 }}
|
||||
<span>{{- .Name -}}</span>
|
||||
</a>
|
||||
|
|
Loading…
Reference in a new issue