From 39a48f35f0ddf668cfe1b5cddbf906df674ecb7a Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Wed, 9 Oct 2024 11:13:11 +0800 Subject: [PATCH] :zap: Perf: if .AlertType not in basic types, rendering to extended alert syntax --- layouts/_default/_markup/render-blockquote-alert.html | 4 +++- layouts/partials/plugin/alert.html | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/layouts/_default/_markup/render-blockquote-alert.html b/layouts/_default/_markup/render-blockquote-alert.html index 91899da6..8e077cf9 100644 --- a/layouts/_default/_markup/render-blockquote-alert.html +++ b/layouts/_default/_markup/render-blockquote-alert.html @@ -1,4 +1,6 @@ -{{- if .AlertTitle -}} +{{- $basicTypes := slice "note" "tip" "important" "warning" "caution" -}} + +{{- if .AlertTitle | or .AlertSign | or (.AlertType | in $basicTypes | not) -}} {{- /* The extended syntax is compatible with Obsidian and FixIt admonition shortcode. */ -}} {{- /* === Dirty hack === */ -}} {{- /* BUG of Hugo https://github.com/gohugoio/hugo/issues/12913 */ -}} diff --git a/layouts/partials/plugin/alert.html b/layouts/partials/plugin/alert.html index 2d78bdba..81a2bc34 100644 --- a/layouts/partials/plugin/alert.html +++ b/layouts/partials/plugin/alert.html @@ -7,11 +7,11 @@ */ -}} {{- $iconMap := dict - "caution" "images/icons/alerts/stop.svg" - "important" "images/icons/alerts/report.svg" "note" "images/icons/alerts/info.svg" "tip" "images/icons/alerts/light-bulb.svg" + "important" "images/icons/alerts/report.svg" "warning" "images/icons/alerts/alert.svg" + "caution" "images/icons/alerts/stop.svg" -}} {{- $attrs := "" }}