From 79883dc7cce2766d6c922e401d46c8ceafe56739 Mon Sep 17 00:00:00 2001 From: Xin Date: Sun, 24 Sep 2023 11:03:34 +0100 Subject: [PATCH] fix: process static image url correctly --- layouts/_default/_markup/render-image.html | 2 +- layouts/shortcodes/card.html | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index e9836a15..21a1e19b 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -10,7 +10,7 @@ {{- if and $dest $isRemote -}} {{- if $startsWithSlash -}} {{/* Images under static directory */}} - {{- $dest = (relURL $dest) -}} + {{- $dest = (relURL (strings.TrimPrefix "/" $dest)) -}} {{- else if and $isPage (not $startsWithRelative) -}} {{/* Images that are sibling to the individual page file */}} {{ $dest = (printf "../%s" $dest) }} diff --git a/layouts/shortcodes/card.html b/layouts/shortcodes/card.html index 562ec3f9..fae0f71e 100644 --- a/layouts/shortcodes/card.html +++ b/layouts/shortcodes/card.html @@ -31,7 +31,9 @@ {{- $image = $processed.RelPermalink -}} {{- else -}} {{/* Otherwise, use relative link of the image */}} - {{- $image = ($image | relURL) -}} + {{- if hasPrefix $image "/" -}} + {{- $image = relURL (strings.TrimPrefix "/" $image) -}} + {{- end -}} {{- end -}} {{- end -}}