Perf: if .AlertType not in basic types, rendering to extended alert syntax

This commit is contained in:
Cell
2024-10-09 11:13:11 +08:00
parent f7670a714b
commit 39a48f35f0
2 changed files with 5 additions and 3 deletions
@@ -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 */ -}}
+2 -2
View File
@@ -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 := "" }}