From f7dac73e74c2fec5abf8eb0b8fb83c23566b456d Mon Sep 17 00:00:00 2001
From: a
Date: Fri, 9 Dec 2022 17:49:33 -0600
Subject: [PATCH] Update support for portable links
---
layouts/_default/_markup/render-link.html | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html
index d349851..9577022 100644
--- a/layouts/_default/_markup/render-link.html
+++ b/layouts/_default/_markup/render-link.html
@@ -1 +1,10 @@
-{{ .Text | safeHTML }}
\ No newline at end of file
+{{ $link := .Destination }}
+{{ $isRemote := strings.HasPrefix $link "http" }}
+{{- if not $isRemote -}}
+{{ $url := urls.Parse .Destination }}
+{{- if $url.Path -}}
+{{ $fragment := "" }}
+{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
+{{- with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .RelPermalink $fragment }}{{ end }}{{ end -}}
+{{- end -}}
+{{ .Text | safeHTML }}
\ No newline at end of file