mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-25 07:48:54 +00:00
8798f5b51f
simpler callouts or admonitions sytax
34 lines
1.1 KiB
HTML
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 -}}
|