From f08a76a738235d1ad8e0b17f74988386dcfd86cd Mon Sep 17 00:00:00 2001 From: SafEight <43656822+SafEight@users.noreply.github.com> Date: Mon, 21 Nov 2022 21:05:46 +0000 Subject: [PATCH] fix: External links ending in .md don't get trimmed (#236) Co-authored-by: SAF fixes https://github.com/jackyzha0/quartz/issues/229 --- layouts/_default/_markup/render-link.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 4757b72..be36d2e 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,9 +1,9 @@ -{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}} -{{$dashedurl := replace $trimmed "%20" "-" }} +{{$dashedurl := replace .Destination "%20" "-" }} {{$external := strings.HasPrefix $dashedurl "http" }} {{- if $external -}} {{ .Text | safeHTML }} {{- else -}} +{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}} {{$spacedurl := replace $trimmed "%20" " " }} {{$fixedUrl := (cond (hasPrefix $spacedurl "/") $spacedurl (print "/" $spacedurl)) | urlize}} {{$nonexistent := eq (.Page.GetPage $spacedurl).RelPermalink ""}}