ensure menu item url has / suffix

This commit is contained in:
Reorx 2022-05-29 21:50:06 +08:00
parent 3398b4c6ab
commit 3b964af770
1 changed files with 3 additions and 3 deletions

View File

@ -118,10 +118,10 @@ window.addEventListener('toggle-theme', function() {
<ul id="menu"> <ul id="menu">
{{- range site.Menus.main }} {{- range site.Menus.main }}
{{- $menu_item_url := (cond (strings.HasSuffix .URL "/") .URL (printf "%s/" .URL)) | absURL }} {{- $menu_item_url := (cond (strings.HasSuffix .URL "/") .URL (printf "%s/" .URL)) | absURL }}
{{- $page_url:= $currentPage.Permalink | absURL }} {{- $page_url:= $currentPage.Permalink }}
{{- $is_search := eq (site.GetPage .KeyName).Layout `search` }} {{- $is_search := eq (site.GetPage .KeyName).Layout `search` }}
<li> <li>
<a href="{{ .URL | absURL }}" title="{{ .Title | default .Name }} {{- cond $is_search (" (Alt + /)" | safeHTMLAttr) ("" | safeHTMLAttr ) }}" <a href="{{ $menu_item_url }}" title="{{ .Title | default .Name }} {{- cond $is_search (" (Alt + /)" | safeHTMLAttr) ("" | safeHTMLAttr ) }}"
{{- if $is_search -}}data-no-instant{{- end -}} {{- if $is_search -}}data-no-instant{{- end -}}
{{- cond $is_search (" accesskey=/" | safeHTMLAttr) ("" | safeHTMLAttr ) }} {{- cond $is_search (" accesskey=/" | safeHTMLAttr) ("" | safeHTMLAttr ) }}
{{- if eq $menu_item_url $page_url }} class="active" {{- end }} {{- if eq $menu_item_url $page_url }} class="active" {{- end }}