1
0
Fork 0
hugo/docs/layouts/_default/_markup/render-blockquote.html

34 lines
1.2 KiB
HTML

{{- if eq .Type "alert" }}
{{- $alerts := dict
"caution" (dict "color" "red" "icon" "exclamation-triangle")
"important" (dict "color" "blue" "icon" "exclamation-circle")
"note" (dict "color" "blue" "icon" "information-circle")
"tip" (dict "color" "green" "icon" "light-bulb")
"warning" (dict "color" "orange" "icon" "exclamation-triangle")
}}
{{- $alertTypes := slice }}
{{- range $k, $_ := $alerts }}
{{- $alertTypes = $alertTypes | append $k }}
{{- end }}
{{- $alertTypes = $alertTypes | sort }}
{{- $alertType := strings.ToLower .AlertType }}
{{- if in $alertTypes $alertType }}
{{- partial "layouts/blocks/alert.html" (dict
"color" (or ((index $alerts $alertType).color) "blue")
"icon" (or ((index $alerts $alertType).icon) "information-circle")
"text" .Text
"title" .AlertTitle
"class" .Attributes.class
)
}}
{{- else }}
{{- errorf `Invalid blockquote alert type. Received %s. Expected one of %s (case-insensitive). See %s.` .AlertType (delimit $alertTypes ", " ", or ") .Page.String }}
{{- end }}
{{- else }}
<blockquote {{- with .Attributes.class }}class="{{ . }}"{{- end }}>
{{ .Text }}
</blockquote>
{{- end }}