Files
FixIt/layouts/_default/_markup/render-blockquote.html
T
2024-08-29 22:30:06 +08:00

34 lines
1.1 KiB
HTML

{{- $icons := 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"
"warning" "images/icons/alerts/alert.svg"
-}}
{{- $Attrs := "" }}
{{- range $key, $value := .Attributes }}
{{- if $value }}
{{- $Attrs = printf "%s %s=%q" $Attrs $key $value }}
{{- end }}
{{- end }}
{{- $Attrs = trim $Attrs " " }}
{{- if eq .Type "alert" -}}
{{- with .Attributes.class }}
{{- $Attrs = trim (replace $Attrs . (printf "alert alert-%s %s" $.AlertType .)) " " }}
{{- else }}
{{- $Attrs = trim (printf "class=%q %s" (printf "alert alert-%s" $.AlertType) $Attrs) " " }}
{{- end -}}
<div {{ $Attrs | safeHTMLAttr }}>
{{- $icon := index $icons .AlertType -}}
<p class="alert-title">
{{- dict "Src" $icon | partial "plugin/icon.html" }}
{{- or (T .AlertType) (title .AlertType) -}}
</p>
{{- .Text | safeHTML -}}
</div>
{{- else -}}
<blockquote {{- with $Attrs }} {{ . | safeHTMLAttr }}{{ end }}>{{ .Text | safeHTML }}</blockquote>
{{- end -}}