From e05950964632cc3975aeed97e500648f25477963 Mon Sep 17 00:00:00 2001 From: razonyang Date: Tue, 14 Nov 2023 22:03:11 +0800 Subject: [PATCH] fix: correct the default thumbnail in the case of baseURL contains subpaths --- .../partials/hb/modules/blog/post/card-img.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/layouts/partials/hb/modules/blog/post/card-img.html b/layouts/partials/hb/modules/blog/post/card-img.html index 60b85c16..fa6799cb 100644 --- a/layouts/partials/hb/modules/blog/post/card-img.html +++ b/layouts/partials/hb/modules/blog/post/card-img.html @@ -7,13 +7,14 @@ {{- $img = index . 0 }} {{- else }} {{- $res := partialCached "hb/functions/page-thumbnail" . . }} - {{- $default := site.Params.hb.blog.post_thumbnail_default }} - {{/* Get the default thumbnail if set. */}} - {{- if and (not $res) $default }} - {{- $res = resources.Get $default }} - {{- end }} - {{- with $res }} - {{- $img = replace .RelPermalink $page.RelPermalink "" | printf "%s?height=360px" }} + {{- if $res }} + {{- $img = replace $res.Permalink $page.Permalink "" | printf "%s?height=360" }} + {{- else }} + {{/* Get the default thumbnail if set. */}} + {{- $default := site.Params.hb.blog.post_thumbnail_default }} + {{- with resources.Get $default }} + {{- $img = strings.TrimPrefix "/" $default | printf "/%s?height=360" }} + {{- end }} {{- end }} {{- end -}} {{- with $img }}