LoveIt/layouts/shortcodes/admonition.html
2020-02-21 23:42:35 +08:00

63 lines
2.7 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 eq (.Get "details") "true" -}}
<details class="admonition {{ $type }}">
{{- with .Get "title" -}}
<summary class="admonition-title">
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}<i class="details {{ $iconDetails }}"></i>
</summary>
{{- end -}}
<div class="admonition-content">
{{- $inner -}}
</div>
</details>
{{- else -}}
<div class="admonition {{ $type }}">
{{- with .Get "title" -}}
<p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}</p>
{{- end -}}
<div class="admonition-content">
{{- $inner -}}
</div>
</div>
{{- end -}}
{{- else -}}
{{- $type := .Get 0 -}}
{{- if eq (.Get 2) "true" -}}
<details class="admonition {{ $type }}">
{{- with .Get 1 -}}
<summary class="admonition-title">
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}<i class="details {{ $iconDetails }}"></i>
</summary>
{{- end -}}
<div class="admonition-content">
{{- $inner -}}
</div>
</details>
{{- else -}}
<div class="admonition {{ $type }}">
{{- with .Get 1 -}}
<p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ . }}</p>
{{- end -}}
<div class="admonition-content">
{{- $inner -}}
</div>
</div>
{{- end -}}
{{- end -}}