From 267c059c4b695550eaf31308f3efeb90f962c02a Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Mon, 27 Oct 2025 05:27:35 +0800 Subject: [PATCH] fix: avoid duplicate base URL for homepage preview images --- _layouts/default.html | 2 +- _layouts/home.html | 35 +++++++++++++++++++++++++++-------- _layouts/post.html | 1 - 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/_layouts/default.html b/_layouts/default.html index a55bfefe9ab..f36c6057b95 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -25,7 +25,7 @@
- {% if layout.refactor or layout.layout == 'default' %} + {% if layout.layout == 'default' %} {% include refactor-content.html content=content lang=lang %} {% else %} {{ content }} diff --git a/_layouts/home.html b/_layouts/home.html index cb9ab244d48..0161ad8fd3c 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -1,6 +1,5 @@ --- layout: default -refactor: true --- {% include lang.html %} @@ -55,19 +54,39 @@ {% if post.image %} {% assign src = post.image.path | default: post.image %} - {% capture src %}{% include media-url.html src=src subpath=post.media_subpath %}{% endcapture %} - {% assign alt = post.image.alt | xml_escape | default: 'Preview Image' %} - - {% assign lqip = null %} + {% if post.media_subpath %} + {% unless src contains '://' %} + {% assign src = post.media_subpath + | append: '/' + | append: src + | replace: '///', '/' + | replace: '//', '/' + %} + {% endunless %} + {% endif %} {% if post.image.lqip %} - {% capture lqip_url %}{% include media-url.html src=post.image.lqip subpath=post.media_subpath %}{% endcapture %} - {% assign lqip = 'lqip="' | append: lqip_url | append: '"' %} + {% assign lqip = post.image.lqip %} + + {% if post.media_subpath %} + {% unless lqip contains 'data:' %} + {% assign lqip = post.media_subpath + | append: '/' + | append: lqip + | replace: '///', '/' + | replace: '//', '/' + %} + {% endunless %} + {% endif %} + + {% assign lqip_attr = 'lqip="' | append: lqip | append: '"' %} {% endif %} + {% assign alt = post.image.alt | xml_escape | default: 'Preview Image' %} +
- {{ alt }} + {{ alt }}
{% assign card_body_col = '7' %} diff --git a/_layouts/post.html b/_layouts/post.html index c8c21ef7986..698c86cf698 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -1,6 +1,5 @@ --- layout: default -refactor: true panel_includes: - toc tail_includes: