| 1 |
{{- if eq .Type "alert" }} |
| 2 |
{{- $alerts := dict |
| 3 |
"caution" (dict "color" "red" "icon" "exclamation-triangle") |
| 4 |
"important" (dict "color" "blue" "icon" "exclamation-circle") |
| 5 |
"note" (dict "color" "blue" "icon" "information-circle") |
| 6 |
"tip" (dict "color" "green" "icon" "light-bulb") |
| 7 |
"warning" (dict "color" "orange" "icon" "exclamation-triangle") |
| 8 |
}} |
| 9 |
|
| 10 |
{{- $alertTypes := slice }} |
| 11 |
{{- range $k, $_ := $alerts }} |
| 12 |
{{- $alertTypes = $alertTypes | append $k }} |
| 13 |
{{- end }} |
| 14 |
{{- $alertTypes = $alertTypes | sort }} |
| 15 |
|
| 16 |
{{- $alertType := strings.ToLower .AlertType }} |
| 17 |
{{- if in $alertTypes $alertType }} |
| 18 |
{{- partial "layouts/blocks/alert.html" (dict |
| 19 |
"color" (or ((index $alerts $alertType).color) "blue") |
| 20 |
"icon" (or ((index $alerts $alertType).icon) "information-circle") |
| 21 |
"text" .Text |
| 22 |
"title" .AlertTitle |
| 23 |
"class" .Attributes.class |
| 24 |
) |
| 25 |
}} |
| 26 |
{{- else }} |
| 27 |
{{- errorf `Invalid blockquote alert type. Received %s. Expected one of %s (case-insensitive). See %s.` .AlertType (delimit $alertTypes ", " ", or ") .Page.String }} |
| 28 |
{{- end }} |
| 29 |
{{- else }} |
| 30 |
<blockquote {{- with .Attributes.class }}class="{{ . }}"{{- end }}> |
| 31 |
{{ .Text }} |
| 32 |
</blockquote> |
| 33 |
{{- end }} |