trwnh.com/unified.test.hugo/layouts/_default/_markup/render-blockquote.html
2024-10-12 13:45:14 -05:00

35 lines
No EOL
2.1 KiB
HTML

{{ if .AlertType }}
{{/* this is an alert/admonition, not a quote */}}
<aside class="admonition{{ with .AlertType }} {{.}}{{end}}">
<header class="admonition-header">
{{ if in (slice "info" "note" "tip" "hint") .AlertType }}
<svg class="admonition__icon info-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><title>info</title><path fill="currentColor" d="M11 17h2v-6h-2zm1-8q.425 0 .713-.288T13 8t-.288-.712T12 7t-.712.288T11 8t.288.713T12 9m0 13q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22"/></svg>
{{ end -}}
{{- if in (slice "warning" "caution" "alert" "notice" "warn") .AlertType }}
<svg class="admonition__icon warning-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><title>warning</title><path fill="currentColor" d="M1 21L12 2l11 19zm11-3q.425 0 .713-.288T13 17t-.288-.712T12 16t-.712.288T11 17t.288.713T12 18m-1-3h2v-5h-2z"/></svg>
{{ end }}
{{ if in (slice "danger" "important") .AlertType}}
<svg class="admonition__icon danger-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 12 12"><title>danger</title><path fill="currentColor" d="M4.283 2.98a1.735 1.735 0 1 1 3.434 0l-.576 4.03a1.153 1.153 0 0 1-2.282 0zM7 10a1 1 0 1 1-2 0a1 1 0 0 1 2 0"/></svg>
{{ end -}}
<p class="admonition__title" aria-hidden="true">{{or .AlertTitle (strings.FirstUpper .AlertType) }}</p>
</header>
<div class="admonition__text">
{{ .Text }}
</div>
</aside>
{{ else }}
{{/* this is a quote, which we can render with an h-cite partial */}}
{{ $datapath := (split (.Attributes.card) "/") }}
{{ $author := .Page.Site.Data.people }}
{{ range $datapath }}
{{ $author = index $author . }}
{{ end }}
{{ $content := .Text }}
{{ $cite := .Attributes.cite }}
{{ $name := .Attributes.name }}
{{ $caption := .Attributes.caption }}
{{ $opts := dict "ctx" . "author" $author "content" $content "cite" $cite "name" $name "caption" $caption }}
{{ partial "mf2/h-cite.html" $opts }}
{{ end }}