File: render-blockquote.html

package info (click to toggle)
hugo 0.155.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 43,600 kB
  • sloc: javascript: 31,879; ansic: 2,350; xml: 350; makefile: 196; sh: 110
file content (33 lines) | stat: -rw-r--r-- 1,222 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{{- 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 }}