From fc9e6efb80da6a646c966c77b1db0deee0975dca Mon Sep 17 00:00:00 2001 From: rxchi1d Date: Mon, 29 Dec 2025 19:26:13 +0800 Subject: [PATCH 1/3] fix(render-blockquote): preserve custom title casing --- layouts/_default/_markup/render-blockquote.html | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/layouts/_default/_markup/render-blockquote.html b/layouts/_default/_markup/render-blockquote.html index 6a8e5afa..18df6cb9 100644 --- a/layouts/_default/_markup/render-blockquote.html +++ b/layouts/_default/_markup/render-blockquote.html @@ -33,11 +33,19 @@ {{- $normalizedType := index $typeMap $rawType | default $rawType -}} {{- $iconName := .Attributes.icon | default (index $iconMap $normalizedType) | default "circle-info" -}} - {{- $admonitionTitle := .AlertTitle | default (i18n (printf "admonition.%s" $normalizedType) | default $normalizedType) -}} + {{- $rawCustomTitle := .AlertTitle | default "" -}} + {{- $trimmedCustomTitle := strings.TrimSpace $rawCustomTitle -}} + {{- $hasCustomTitle := ne $trimmedCustomTitle "" -}} + {{- $defaultTitle := i18n (printf "admonition.%s" $normalizedType) | default $normalizedType -}} + {{- $admonitionTitle := cond $hasCustomTitle $rawCustomTitle $defaultTitle -}} {{- $containerClass := "admonition relative overflow-hidden rounded-lg border-l-4 my-3 px-4 py-3 shadow-sm" -}} - {{- $headerClass := "flex items-center gap-2 font-semibold text-inherit capitalize" -}} + {{- $headerClass := "flex items-center gap-2 font-semibold text-inherit" -}} {{- $contentClass := "admonition-content mt-3 text-base leading-relaxed text-inherit" -}} + {{- $titleClass := "grow" -}} + {{- if not $hasCustomTitle -}} + {{- $titleClass = printf "%s %s" $titleClass "capitalize" -}} + {{- end -}} {{- $isCollapsible := in (slice "+" "-") .AlertSign -}} {{- if $isCollapsible -}} @@ -49,7 +57,7 @@
{{- partial "icon.html" $iconName -}}
-
+
{{ $admonitionTitle }}
{{- partial "icon.html" $iconName -}}
-
+
{{ $admonitionTitle }}
From 966828efff046c3763387fc4ff24eec8960589c4 Mon Sep 17 00:00:00 2001 From: rxchi1d Date: Sat, 27 Dec 2025 13:29:46 +0800 Subject: [PATCH 2/3] fix(i18n): add admonition titles for en --- i18n/en.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/i18n/en.yaml b/i18n/en.yaml index bcb43484..b9903ae0 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -85,3 +85,20 @@ shortcode: recent: show_more: "Show More" + +admonition: + abstract: "Abstract" + bug: "Bug" + caution: "Caution" + danger: "Danger" + example: "Example" + failure: "Failure" + important: "Important" + info: "Info" + note: "Note" + question: "Question" + quote: "Quote" + success: "Success" + tip: "Tip" + todo: "Todo" + warning: "Warning" From 17906e63e2f56fe465e8ed814b6596c26eecf240 Mon Sep 17 00:00:00 2001 From: rxchi1d Date: Sun, 4 Jan 2026 23:25:28 +0800 Subject: [PATCH 3/3] refactor(admonition): simplify title handling logic Replace complex title processing (9 lines) with single-line title filter approach. Changes: - Simplify $admonitionTitle definition from 5 variables to 1 line - Remove $titleClass conditional logic (4 lines) - Replace dynamic CSS class with static "grow" class - Use Hugo title filter instead of CSS capitalize - Remove TrimSpace processing per author feedback This maintains the same visual behavior while significantly reducing code complexity. Related: PR #2704 feedback from ZhenShuo2021 --- layouts/_default/_markup/render-blockquote.html | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/layouts/_default/_markup/render-blockquote.html b/layouts/_default/_markup/render-blockquote.html index 18df6cb9..e68534dc 100644 --- a/layouts/_default/_markup/render-blockquote.html +++ b/layouts/_default/_markup/render-blockquote.html @@ -33,19 +33,11 @@ {{- $normalizedType := index $typeMap $rawType | default $rawType -}} {{- $iconName := .Attributes.icon | default (index $iconMap $normalizedType) | default "circle-info" -}} - {{- $rawCustomTitle := .AlertTitle | default "" -}} - {{- $trimmedCustomTitle := strings.TrimSpace $rawCustomTitle -}} - {{- $hasCustomTitle := ne $trimmedCustomTitle "" -}} - {{- $defaultTitle := i18n (printf "admonition.%s" $normalizedType) | default $normalizedType -}} - {{- $admonitionTitle := cond $hasCustomTitle $rawCustomTitle $defaultTitle -}} + {{- $admonitionTitle := .AlertTitle | default ((i18n (printf "admonition.%s" $normalizedType) | default $normalizedType) | title) -}} {{- $containerClass := "admonition relative overflow-hidden rounded-lg border-l-4 my-3 px-4 py-3 shadow-sm" -}} {{- $headerClass := "flex items-center gap-2 font-semibold text-inherit" -}} {{- $contentClass := "admonition-content mt-3 text-base leading-relaxed text-inherit" -}} - {{- $titleClass := "grow" -}} - {{- if not $hasCustomTitle -}} - {{- $titleClass = printf "%s %s" $titleClass "capitalize" -}} - {{- end -}} {{- $isCollapsible := in (slice "+" "-") .AlertSign -}} {{- if $isCollapsible -}} @@ -57,7 +49,7 @@
{{- partial "icon.html" $iconName -}}
-
+
{{ $admonitionTitle }}
{{- partial "icon.html" $iconName -}}
-
+
{{ $admonitionTitle }}