From aec737ff16db2067dedf9f93bc7441aa7c06adc4 Mon Sep 17 00:00:00 2001
From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com>
Date: Sun, 27 Jul 2025 00:37:40 +0800
Subject: [PATCH 1/2] fix(carousel): make interval affect slide transition on
click
---
layouts/shortcodes/carousel.html | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/layouts/shortcodes/carousel.html b/layouts/shortcodes/carousel.html
index e719a8d3..b99ec2c9 100644
--- a/layouts/shortcodes/carousel.html
+++ b/layouts/shortcodes/carousel.html
@@ -16,6 +16,14 @@
{{ end }}
{{ end }}
+
Date: Sun, 27 Jul 2025 00:58:08 +0800
Subject: [PATCH 2/2] chore(carosel): prevent style tag in HTML
this approach does not need to change the assets or the vendor file
and the live reload is also supported
---
layouts/shortcodes/carousel.html | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/layouts/shortcodes/carousel.html b/layouts/shortcodes/carousel.html
index b99ec2c9..1355e874 100644
--- a/layouts/shortcodes/carousel.html
+++ b/layouts/shortcodes/carousel.html
@@ -2,6 +2,20 @@
{{ $aspect := default "16-9" (.Get "aspectRatio") }}
{{ $interval := default "2000" (.Get "interval") }}
+{{ $carouselItemCSS := printf
+`
+ #%s [data-twe-carousel-item] {
+ transition-duration: %sms !important;
+}` $id $interval }}
+{{ $carouselInitCSS := printf
+`
+#%s [data-twe-carousel-init] {
+ --twe-carousel-interval: %s;
+}` $id $interval }}
+{{ $cssContent := printf "%s%s" $carouselItemCSS $carouselInitCSS }}
+{{ $css := resources.FromString (printf "css/carousel-%s.css" $id) $cssContent | minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }}
+
+
{{ $page := .Page.Resources }}
{{ $imagesTemp := .Get "images" }}
{{ $imagesTemp = strings.TrimPrefix "{" $imagesTemp }}
@@ -16,14 +30,6 @@
{{ end }}
{{ end }}
-