LoveIt/layouts/shortcodes/admonition.html

64 lines
2.7 KiB
HTML
Raw Normal View History

2020-02-18 09:22:24 +01:00
{{- $inner := .Inner | .Page.RenderString -}}
2020-01-31 15:53:04 +01:00
{{- $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 -}}
2020-02-02 14:07:38 +01:00
{{- $iconDetails := "fas fa-angle-down" -}}
2020-01-31 15:53:04 +01:00
{{- if .IsNamedParams -}}
2020-02-02 14:07:38 +01:00
{{- $type := .Get "type" | default "note" -}}
2020-01-31 15:53:04 +01:00
{{- if eq (.Get "details") "true" -}}
<details class="admonition {{ $type }}">
2020-01-31 15:53:04 +01:00
{{- with .Get "title" -}}
<summary class="admonition-title">
2020-02-02 14:07:38 +01:00
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}<i class="details {{ $iconDetails }}"></i>
2020-01-31 15:53:04 +01:00
</summary>
{{- end -}}
2020-02-21 16:42:35 +01:00
<div class="admonition-content">
{{- $inner -}}
</div>
2019-08-11 19:36:19 +02:00
</details>
{{- else -}}
<div class="admonition {{ $type }}">
2020-01-31 15:53:04 +01:00
{{- with .Get "title" -}}
2020-02-02 14:07:38 +01:00
<p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}</p>
2020-01-31 15:53:04 +01:00
{{- end -}}
2020-02-21 16:42:35 +01:00
<div class="admonition-content">
{{- $inner -}}
</div>
2019-08-11 19:36:19 +02:00
</div>
{{- end -}}
2020-01-31 15:53:04 +01:00
{{- else -}}
{{- $type := .Get 0 -}}
{{- if eq (.Get 2) "true" -}}
<details class="admonition {{ $type }}">
2020-01-31 15:53:04 +01:00
{{- with .Get 1 -}}
<summary class="admonition-title">
2020-02-02 14:07:38 +01:00
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}<i class="details {{ $iconDetails }}"></i>
2020-01-31 15:53:04 +01:00
</summary>
{{- end -}}
2020-02-21 16:42:35 +01:00
<div class="admonition-content">
{{- $inner -}}
</div>
2019-08-11 19:36:19 +02:00
</details>
{{- else -}}
<div class="admonition {{ $type }}">
2020-01-31 15:53:04 +01:00
{{- with .Get 1 -}}
2020-02-02 14:07:38 +01:00
<p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}</p>
2020-01-31 15:53:04 +01:00
{{- end -}}
2020-02-21 16:42:35 +01:00
<div class="admonition-content">
{{- $inner -}}
</div>
2019-08-11 19:36:19 +02:00
</div>
{{- end -}}
2020-02-06 17:10:00 +01:00
{{- end -}}