From cdbb3f751a08b208353d3ed190618796a78563b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Wed, 25 May 2022 15:44:10 +0800 Subject: [PATCH] :construction_worker: Add sidebar menu items. --- exampleSite/config.yaml | 38 ++++++++++++++++++++++++++---- i18n/en-us.yaml | 3 +++ i18n/zh-cn.yaml | 3 +++ layouts/_default/baseof.html | 2 ++ layouts/partials/header.html | 3 ++- layouts/partials/header/menus.html | 27 +++++++++++++++++++++ 6 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 layouts/partials/header/menus.html diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 303616d..bbcfea2 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -23,6 +23,34 @@ languages: subtitle: Theme for Hugo description: Stay easily & powerful. +#-------------------------------------- +# Menus Settings +# Attribute pre is Font Awesome icon name without prefix "fa-". +# External url should start with http:// or https:// . +# ------------------------------------- +menus: + main: + - identifier: home + name: 首页 + url: / + pre: home + weight: 1 + - identifier: about + name: 关于 + url: /ablout.html + pre: user + weight: 2 + - identifier: archives + name: 归档 + url: /archives + pre: archive + weight: 3 + - identifier: commonweal + name: 公益 404 + url: /404.html + pre: heartbeat + weight: 4 + params: # --------------------------------------------------------------- # Theme Core Configuration Settings @@ -118,7 +146,7 @@ params: # Key is the name of menu item. If the translation for this item is available, the translated text will be loaded, otherwise the Key name will be used. Key is case-sensitive. # Value before `||` delimiter is the target link, value after `||` delimiter is the name of Font Awesome icon. # External url should start with http:// or https:// - menu: + #menu: #home: / || fa fa-home #about: /about/ || fa fa-user #tags: /tags/ || fa fa-tags @@ -131,7 +159,7 @@ params: # Enable / Disable menu icons / item badges. menuSets: icons: true - badges: false + badges: true # --------------------------------------------------------------- @@ -766,7 +794,7 @@ params: # Local Search # Dependencies: https://github.com/next-theme/hexo-generator-searchdb localSearch: - enable: false + enable: true # If auto, trigger search by changing input. # If manual, trigger search by pressing enter key or search button. trigger: auto @@ -909,7 +937,7 @@ params: # The default CDN provider of third-party plugins. # Available values: local | jsdelivr | unpkg | cdnjs | custom # Dependencies for `plugins: local`: https://github.com/next-theme/plugins - plugins: cdnjs + plugins: unpkg # Custom CDN URL # For example: # custom_cdn_url: https://cdn.jsdelivr.net/npm/${npm_name}@${version}/${minified} @@ -921,6 +949,6 @@ params: # The js option is only valid when vendors.internal is local. css: css js: js - images: images + images: imgs diff --git a/i18n/en-us.yaml b/i18n/en-us.yaml index b4ca595..2904657 100644 --- a/i18n/en-us.yaml +++ b/i18n/en-us.yaml @@ -5,6 +5,9 @@ NavToggleLabel: other: Toggle navigation bar +MSearchLabel: + other: Search + ColoneFlag: other: ":" diff --git a/i18n/zh-cn.yaml b/i18n/zh-cn.yaml index 7451151..49b2eb5 100644 --- a/i18n/zh-cn.yaml +++ b/i18n/zh-cn.yaml @@ -5,6 +5,9 @@ NavToggleLabel: other: 切换导航栏 +MSearchLabel: + other: 搜索 + ColoneFlag: other: ":" diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 4f23cac..7bb5e52 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -5,6 +5,8 @@ {{- $pluginVen := $P.vendors.plugins -}} {{- $pluginCDN := index $vendors $pluginVen -}} {{- .Scratch.Set "pluginCDN" $pluginCDN -}} +{{ $posts := len .Site.RegularPages }} +{{- .Scratch.Set "posts" $posts -}} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index bf3bd31..cda1966 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1 +1,2 @@ -{{ partial "header/brand" . }} \ No newline at end of file +{{ partial "header/brand" . }} +{{ partial "header/menus" . }} \ No newline at end of file diff --git a/layouts/partials/header/menus.html b/layouts/partials/header/menus.html new file mode 100644 index 0000000..ba85a69 --- /dev/null +++ b/layouts/partials/header/menus.html @@ -0,0 +1,27 @@ +{{- $ms := .P.menuSets }} +{{- $curP := .Page }} +{{- $post := .Scratch.Get "posts" }} + \ No newline at end of file