refactor(sidebar): drop support for .Pre and remove old codes (#1271)

* refactor(sidebar): drop support for .Pre and remove old codes

* Simplify
This commit is contained in:
Jimmy
2026-02-19 17:49:50 +01:00
committed by GitHub
parent 2be5b48324
commit bd7a34966c
+3 -7
View File
@@ -35,7 +35,7 @@
<li> <li>
<a <a
href='{{ .URL }}' href='{{ .URL }}'
{{ if eq (default true .Params.newTab) true }}target="_blank"{{ end }} {{ if .Params.newTab }}target="_blank"{{ end }}
{{ with .Name }}title="{{ . }}"{{ end }} {{ with .Name }}title="{{ . }}"{{ end }}
rel="me" rel="me"
> >
@@ -54,12 +54,8 @@
{{ range .Site.Menus.main }} {{ range .Site.Menus.main }}
{{ $active := or (eq $currentPage.RelPermalink .URL) (or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .)) }} {{ $active := or (eq $currentPage.RelPermalink .URL) (or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .)) }}
<li {{ if $active }} class='current'{{ end }}> <li {{ if $active }} class='current'{{ end }}>
<a href='{{ .URL }}' {{ if eq .Params.newTab true }}target="_blank"{{ end }}> <a href='{{ .URL }}' {{ if .Params.newTab }}target="_blank"{{ end }}>
{{ $icon := default .Pre .Params.Icon }} {{ with .Params.Icon }}
{{ if .Pre }}
{{ warnf "Menu item [%s] is using [pre] field to set icon, please use [params.icon] instead.\nMore information: https://stack.jimmycai.com/config/menu" .URL }}
{{ end }}
{{ with $icon }}
{{ partial "helper/icon" . }} {{ partial "helper/icon" . }}
{{ end }} {{ end }}
<span>{{- .Name -}}</span> <span>{{- .Name -}}</span>