LoveIt/layouts/shortcodes/admonition.html

59 lines
2.8 KiB
HTML

{{- $inner := .Inner | .Page.RenderString -}}
{{- $iconMap := dict "note" "fas fa-pencil-alt" -}}
{{- $iconMap = dict "abstract" "fas fa-list-ul" | merge $iconMap -}}
{{- $iconMap = dict "info" "fas fa-info-circle" | merge $iconMap -}}
{{- $iconMap = dict "tip" "fas fa-lightbulb" | merge $iconMap -}}
{{- $iconMap = dict "success" "fas fa-check-circle" | merge $iconMap -}}
{{- $iconMap = dict "question" "fas fa-question-circle" | merge $iconMap -}}
{{- $iconMap = dict "warning" "fas fa-exclamation-triangle" | merge $iconMap -}}
{{- $iconMap = dict "failure" "fas fa-times-circle" | merge $iconMap -}}
{{- $iconMap = dict "danger" "fas fa-skull-crossbones" | merge $iconMap -}}
{{- $iconMap = dict "bug" "fas fa-bug" | merge $iconMap -}}
{{- $iconMap = dict "example" "fas fa-list-ol" | merge $iconMap -}}
{{- $iconMap = dict "quote" "fas fa-quote-right" | merge $iconMap -}}
{{- $iconDetails := "fas fa-angle-down" -}}
{{- if .IsNamedParams -}}
{{- $type := .Get "type" | default "note" -}}
{{- if .Get "details" -}}
<div class="details admonition {{ $type }}">
<div class="details-summary admonition-title">
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get "title" | default (T $type) }}<i class="details-icon {{ $iconDetails }}"></i>
</div>
<div class="details-content">
<div class="admonition-content">
{{- $inner -}}
</div>
</div>
</div>
{{- else -}}
<div class="admonition {{ $type }}">
<div class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get "title" | default (T $type) }}</div>
<div class="admonition-content">
{{- $inner -}}
</div>
</div>
{{- end -}}
{{- else -}}
{{- $type := .Get 0 | default "note" -}}
{{- if .Get 2 -}}
<div class="details admonition {{ $type }}">
<div class="details-summary admonition-title">
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get 1 | default (T $type) }}<i class="details-icon {{ $iconDetails }}"></i>
</div>
<div class="details-content">
<div class="admonition-content">
{{- $inner -}}
</div>
</div>
</div>
{{- else -}}
<div class="admonition {{ $type }}">
<div class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get 1 | default (T $type) }}</div>
<div class="admonition-content">
{{- $inner -}}
</div>
</div>
{{- end -}}
{{- end -}}