From 66bf232951fbe752821b623dc1e7e4e2824c15bf Mon Sep 17 00:00:00 2001
From: Cotes <11371340+cotes2020@users.noreply.github.com>
Date: Mon, 27 Oct 2025 05:39:39 +0800
Subject: [PATCH] fix: avoid duplicate base URL for homepage preview images
(#2568)
---
_layouts/default.html | 2 +-
_layouts/home.html | 39 +++++++++++++++++++++++++++++----------
_layouts/post.html | 1 -
3 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/_layouts/default.html b/_layouts/default.html
index a55bfefe9..f36c6057b 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -25,7 +25,7 @@ layout: compress
- {% 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 cb9ab244d..0161ad8fd 100644
--- a/_layouts/home.html
+++ b/_layouts/home.html
@@ -1,6 +1,5 @@
---
layout: default
-refactor: true
---
{% include lang.html %}
@@ -55,19 +54,39 @@ refactor: true
{% if post.image %}
{% assign src = post.image.path | default: post.image %}
- {% capture src %}{% include media-url.html src=src subpath=post.media_subpath %}{% endcapture %}
+
+ {% if post.media_subpath %}
+ {% unless src contains '://' %}
+ {% assign src = post.media_subpath
+ | append: '/'
+ | append: src
+ | replace: '///', '/'
+ | replace: '//', '/'
+ %}
+ {% endunless %}
+ {% endif %}
+
+ {% if post.image.lqip %}
+ {% 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' %}
- {% assign lqip = null %}
-
- {% 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: '"' %}
- {% endif %}
-
-

+
{% assign card_body_col = '7' %}
diff --git a/_layouts/post.html b/_layouts/post.html
index c8c21ef79..698c86cf6 100644
--- a/_layouts/post.html
+++ b/_layouts/post.html
@@ -1,6 +1,5 @@
---
layout: default
-refactor: true
panel_includes:
- toc
tail_includes: