Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CaiJimmy/hugo-theme-stack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Cai <github@jimmycai.com>2021-10-23 10:18:44 +0300
committerGitHub <noreply@github.com>2021-10-23 10:18:44 +0300
commit7c59ac77137a9bbf2d9b4430aeca7006fb044da0 (patch)
tree0a84ea3ba5624c934d9a2a5a03734c5525ec1444
parenta822411a030663c8acaf399c349b7462da467d92 (diff)
refactor(menu): use .Params.icon to configure menu item icon (#400)
-rw-r--r--exampleSite/config.yaml2
-rw-r--r--exampleSite/content/page/about.md3
-rw-r--r--exampleSite/content/page/archives.md3
-rw-r--r--exampleSite/content/page/search.md3
-rw-r--r--layouts/partials/sidebar/left.html6
5 files changed, 12 insertions, 5 deletions
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index a285296..d5cf58d 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -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
diff --git a/exampleSite/content/page/about.md b/exampleSite/content/page/about.md
index 79898de..494cb46 100644
--- a/exampleSite/content/page/about.md
+++ b/exampleSite/content/page/about.md
@@ -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.
diff --git a/exampleSite/content/page/archives.md b/exampleSite/content/page/archives.md
index 027dfc6..2862deb 100644
--- a/exampleSite/content/page/archives.md
+++ b/exampleSite/content/page/archives.md
@@ -6,5 +6,6 @@ slug: "archives"
menu:
main:
weight: -70
- pre: archives
+ params:
+ icon: archives
---
diff --git a/exampleSite/content/page/search.md b/exampleSite/content/page/search.md
index f54cdb5..b2a5943 100644
--- a/exampleSite/content/page/search.md
+++ b/exampleSite/content/page/search.md
@@ -8,5 +8,6 @@ outputs:
menu:
main:
weight: -60
- pre: search
+ params:
+ icon: search
--- \ No newline at end of file
diff --git a/layouts/partials/sidebar/left.html b/layouts/partials/sidebar/left.html
index 53a6655..9d4dd3e 100644
--- a/layouts/partials/sidebar/left.html
+++ b/layouts/partials/sidebar/left.html
@@ -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>