From 74e53cc7d2a81af0ca978818faa2a7d280cc9a41 Mon Sep 17 00:00:00 2001 From: stereobooster Date: Tue, 19 Sep 2023 06:59:55 +0200 Subject: [PATCH 1/2] Markdown portable links --- layouts/_default/_markup/render-link.html | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 5408216c..4592eb95 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,7 +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 }} From 95f04231af0a1aca094ad2b399c00f87337ad12e Mon Sep 17 00:00:00 2001 From: stereobooster Date: Mon, 23 Oct 2023 01:55:35 +0200 Subject: [PATCH 2/2] add rel=noreferrer --- layouts/_default/_markup/render-link.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 4592eb95..e42c035c 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -7,4 +7,4 @@ {{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}} {{- with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .RelPermalink $fragment }}{{ end }}{{ end -}} {{- end -}} -{{ .Text | safeHTML }} +{{ .Text | safeHTML }}