From 94968bbbe14604c58aae1034797810f8e56d8660 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Sat, 11 Oct 2025 17:45:43 +0800 Subject: [PATCH] feat: add support for center-aligned alerts in admonition syntax (#640) --- apps/test/content/posts/alert-and-admonition-test.md | 5 +++++ layouts/_markup/render-blockquote-alert.html | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/test/content/posts/alert-and-admonition-test.md b/apps/test/content/posts/alert-and-admonition-test.md index f959ac97..2e01fc73 100644 --- a/apps/test/content/posts/alert-and-admonition-test.md +++ b/apps/test/content/posts/alert-and-admonition-test.md @@ -154,3 +154,8 @@ This is the default example type admonition. {{< admonition quote "" false >}} This is the default quote type admonition. Aliases: `cite` {{< /admonition >}} + +## Special Types + +> [!center] +> This paragraph is **center-aligned**. diff --git a/layouts/_markup/render-blockquote-alert.html b/layouts/_markup/render-blockquote-alert.html index a065ccc2..6acf3787 100644 --- a/layouts/_markup/render-blockquote-alert.html +++ b/layouts/_markup/render-blockquote-alert.html @@ -1,6 +1,9 @@ {{- $basicTypes := slice "note" "tip" "important" "warning" "caution" -}} -{{- if .AlertTitle | or .AlertSign | or (.AlertType | in $basicTypes | not) -}} +{{- if eq .AlertType "center" -}} + {{- /* The "center" type is a special case for centering content. */ -}} +
{{ .Text }}
+{{- else if .AlertTitle | or .AlertSign | or (.AlertType | in $basicTypes | not) -}} {{- /* The extended syntax is compatible with Obsidian and FixIt admonition shortcode. */ -}} {{- $openMap := dict "+" true "-" false -}} {{- $open := index $openMap .AlertSign | default true -}}