From e6733b5e9d2e11c89bd65a3f0588f1afc50be6f0 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 4757b728..be36d2e9 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 ""}}