Add site menus parameters.

This commit is contained in:
凡梦星尘 2022-05-12 11:04:28 +08:00
parent 0b53308c2d
commit f879f77dab
2 changed files with 40 additions and 21 deletions

View File

@ -24,6 +24,35 @@ languages:
subtitle: Theme for Hugo subtitle: Theme for Hugo
description: Stay easily & powerful. 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
# ------------------------------------- # -------------------------------------
# User-define Settings # User-define Settings
# ------------------------------------- # -------------------------------------
@ -31,8 +60,6 @@ params:
# ------------------------------------- # -------------------------------------
# Scheme Settings # Scheme Settings
# ------------------------------------- # -------------------------------------
# Schemes
#scheme: Muse #scheme: Muse
#scheme: Mist #scheme: Mist
#scheme: Pisces #scheme: Pisces
@ -72,6 +99,9 @@ params:
# admins: <fb:admin_id> # admins: <fb:admin_id>
# app_id: <fb:app_id> # app_id: <fb:app_id>
#--------------------------------------
# Sidebar Settings
# -------------------------------------
sidebar: sidebar:
# Sidebar Position. # Sidebar Position.
#position: left | right #position: left | right

View File

@ -1,23 +1,12 @@
<ul class="main-menu menu"> <ul class="main-menu menu">
<li class="menu-item menu-item-home"> {{- $curP := . }}
<a href="/" rel="section"> {{- range .Site.Menus.main }}
<i class="fa fa-home fa-fw"></i>首页 {{ $active := or ($curP.IsMenuCurrent "main" .) ($curP.HasMenuCurrent "main" .) }}
</a> {{ $active = or $active (eq .URL "/")}}
</li> <li class="menu-item menu-item-{{ .Identifier }}">
<li class="menu-item menu-item-about"> <a href="{{ .URL }}" class="hvr-icon-pulse{{if $active }} menu-item-active{{ end }}" rel="section">
<a href="/about/" rel="section"> <i class="fa fa-{{ .Pre }} hvr-icon"></i>{{- .Name }}
<i class="fa fa-user fa-fw"></i>关于
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section">
<i class="fa fa-archive fa-fw"></i>归档
</a>
</li>
<li class="menu-item menu-item-commonweal">
<a href="/404/" rel="section">
<i class="fa fa-heartbeat fa-fw"></i>公益 404
</a> </a>
</li> </li>
{{- end }}
</ul> </ul>