Simplify and align detection of remote links

This commit is contained in:
Alex Shpak
2025-09-21 22:29:59 +02:00
parent 79001ff6f3
commit 69fb3210e8
4 changed files with 5 additions and 5 deletions
@@ -1,7 +1,7 @@
{{- $destination := .Destination -}}
{{- $url := urls.Parse .Destination -}}
{{- $isRemote := gt (len $url.Host) 0 -}}
{{- $isRemote := $url.IsAbs -}}
{{- $isFragment := strings.HasPrefix .Destination "#" -}}
{{- if and (not $isRemote) (not $isFragment) -}}
@@ -1,7 +1,7 @@
{{- $destination := .Destination -}}
{{- $url := urls.Parse .Destination -}}
{{- $isRemote := gt (len $url.Host) 0 -}}
{{- $isRemote := $url.IsAbs -}}
{{- $isFragment := strings.HasPrefix .Destination "#" -}}
{{- if and (not $isRemote) (not $isFragment) -}}
+1 -1
View File
@@ -17,7 +17,7 @@
{{- $class = $class | append "active" -}}
{{- end -}}
<li>
{{- $isRemote := not (or (.Page) (strings.HasPrefix .URL "/")) -}}
{{- $isRemote := (urls.Parse .URL).IsAbs -}}
<a href="{{ .URL }}"
{{- with $class }}class="{{ delimit . " " }}"{{ end -}}
{{- with .Title }}title="{{ . }}"{{ end -}}