mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2026-11-22 12:39:04 +00:00
perf(header): hoist page url out of menu loop
- compute the current page url once instead of per menu item - use strings.Contains instead of findRE to detect external links
This commit is contained in:
1 file changed
+2
-3
@@ -81,11 +81,10 @@
|
||||
</div>
|
||||
{{- end }}
|
||||
</div>
|
||||
{{- $currentPage := . }}
|
||||
{{- $page_url:= .Permalink | absLangURL }}
|
||||
<ul id="menu" class="menu">
|
||||
{{- range site.Menus.main }}
|
||||
{{- $menu_item_url := (cond (strings.HasSuffix .URL "/") .URL (printf "%s/" .URL) ) | absLangURL }}
|
||||
{{- $page_url:= $currentPage.Permalink | absLangURL }}
|
||||
{{- $is_search := eq (site.GetPage .KeyName).Layout `search` }}
|
||||
<li>
|
||||
<a href="{{ .URL | absLangURL }}" title="{{ .Title | default .Name }} {{- cond $is_search (" (Alt + /)" | safeHTMLAttr) ("" | safeHTMLAttr ) }}"
|
||||
@@ -95,7 +94,7 @@
|
||||
{{- .Name -}}
|
||||
{{ .Post -}}
|
||||
</span>
|
||||
{{- if (findRE "://" .URL) }}
|
||||
{{- if (strings.Contains .URL "://") }}
|
||||
<svg fill="none" shape-rendering="geometricPrecision" stroke="currentColor" stroke-linecap="round"
|
||||
stroke-linejoin="round" stroke-width="2.5" viewBox="0 0 24 24" height="12" width="12">
|
||||
<path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"></path>
|
||||
|
||||
Reference in new issue
Block a user