From e70c968e567b2673baafc3bac6524220c9e76f38 Mon Sep 17 00:00:00 2001 From: stereobooster Date: Tue, 31 Oct 2023 16:54:45 +0100 Subject: [PATCH] Print warning if system can't resolve link to a markdown file --- layouts/_default/_markup/render-link.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index d0d013ae..578bfcef 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -2,10 +2,16 @@ {{ $isRemote := strings.HasPrefix $link "http" }} {{- if not $isRemote }} {{ $url := urls.Parse .Destination }} - {{ if $url.Path }} + {{- if $url.Path }} {{ $fragment := "" }} {{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}} - {{- with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .RelPermalink $fragment }}{{ end -}} - {{ end }} + {{- with .Page.GetPage $url.Path }} + {{ $link = printf "%s%s" .RelPermalink $fragment }} + {{ else }} + {{- if hasSuffix $url.Path ".md" }} + {{ warnf "Can't resolve: %s" .Destination }} + {{ end -}} + {{ end -}} + {{ end -}} {{ end -}} {{- .Text | safeHTML -}} \ No newline at end of file