From 69fb3210e8682e8760aefea715f14997f0f679c2 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Sun, 21 Sep 2025 22:29:59 +0200 Subject: [PATCH] Simplify and align detection of remote links --- layouts/_partials/docs/links/portable-image.html | 2 +- layouts/_partials/docs/links/portable-link.html | 2 +- layouts/_partials/docs/menu-hugo.html | 2 +- layouts/_shortcodes/button.html | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/layouts/_partials/docs/links/portable-image.html b/layouts/_partials/docs/links/portable-image.html index 4b9bc44..a65f2b2 100644 --- a/layouts/_partials/docs/links/portable-image.html +++ b/layouts/_partials/docs/links/portable-image.html @@ -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) -}} diff --git a/layouts/_partials/docs/links/portable-link.html b/layouts/_partials/docs/links/portable-link.html index 4c5c0c0..5a52ef3 100644 --- a/layouts/_partials/docs/links/portable-link.html +++ b/layouts/_partials/docs/links/portable-link.html @@ -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) -}} diff --git a/layouts/_partials/docs/menu-hugo.html b/layouts/_partials/docs/menu-hugo.html index 76c5fd8..137653b 100644 --- a/layouts/_partials/docs/menu-hugo.html +++ b/layouts/_partials/docs/menu-hugo.html @@ -17,7 +17,7 @@ {{- $class = $class | append "active" -}} {{- end -}}
  • - {{- $isRemote := not (or (.Page) (strings.HasPrefix .URL "/")) -}} + {{- $isRemote := (urls.Parse .URL).IsAbs -}} {{- .InnerDeindent -}}