🐛 Fixed menu active action.

This commit is contained in:
凡梦星尘 2022-06-24 19:12:08 +08:00
parent 5630e240df
commit 44bf318330
3 changed files with 9 additions and 11 deletions

View File

@ -48,17 +48,17 @@ languages:
main: main:
- identifier: home - identifier: home
name: Home name: Home
url: / pageref: /
pre: home pre: home
weight: 1 weight: 1
- identifier: about - identifier: about
name: About name: About
url: /about.html pageref: /about.html
pre: user pre: user
weight: 2 weight: 2
- identifier: archives - identifier: archives
name: Archives name: Archives
url: /posts pageref: /posts
pre: archive pre: archive
weight: 3 weight: 3
- identifier: commonweal - identifier: commonweal
@ -86,17 +86,17 @@ menus:
main: main:
- identifier: home - identifier: home
name: 首页 name: 首页
url: / pageref: /
pre: home pre: home
weight: 1 weight: 1
- identifier: about - identifier: about
name: 关于 name: 关于
url: /about.html pageref: /about.html
pre: user pre: user
weight: 2 weight: 2
- identifier: archives - identifier: archives
name: 归档 name: 归档
url: /posts pageref: /posts
pre: archive pre: archive
weight: 3 weight: 3
- identifier: commonweal - identifier: commonweal

View File

@ -2,13 +2,12 @@
{{- $curP := .Page }} {{- $curP := .Page }}
<nav class="site-nav"> <nav class="site-nav">
<ul class="main-menu menu"> <ul class="main-menu menu">
{{- range $curP.Site.Menus.main }} {{- range .Site.Menus.main }}
{{- $active := or ($curP.IsMenuCurrent "main" .) ($curP.HasMenuCurrent "main" .) }} {{- $active := $curP.IsMenuCurrent "main" . }}
{{- $active = or $active (eq .URL "/")}}
<li class="menu-item menu-item-{{ .Identifier }}"> <li class="menu-item menu-item-{{ .Identifier }}">
<a href="{{ .URL | relLangURL }}" class="hvr-icon-pulse {{if $active }} menu-item-active{{ end }}" rel="section"> <a href="{{ .URL | relLangURL }}" class="hvr-icon-pulse {{if $active }} menu-item-active{{ end }}" rel="section">
{{- if $ms.icons }}<i class="fa fa-{{ .Pre }} hvr-icon"></i>{{ end }}{{- .Name }} {{- if $ms.icons }}<i class="fa fa-{{ .Pre }} hvr-icon"></i>{{ end }}{{- .Name }}
{{- if and $ms.badges (eq .Identifier "archives" ) }} {{- if and $ms.badges (eq .Identifier "archives") }}
<span class="badge">{{ $.Scratch.Get "postsCount" }}</span> <span class="badge">{{ $.Scratch.Get "postsCount" }}</span>
{{- end }} {{- end }}
</a> </a>

View File

@ -60,7 +60,6 @@
{{- end }} {{- end }}
</div> </div>
{{- $lang := .Scratch.Get "lang" }}
{{- with .Site.Params.creativeCommons }} {{- with .Site.Params.creativeCommons }}
{{- if .sidebar }} {{- if .sidebar }}
<div class="cc-license animated" itemprop="license"> <div class="cc-license animated" itemprop="license">