hugo-theme-relearn/layouts/partials/shortcodes/expand.html
2023-05-18 14:01:50 +02:00

22 lines
No EOL
855 B
HTML

{{- $context := .context }}
{{- $content := .content }}
{{- $title := .title | default (T "Expand-title") }}
{{- $title = trim $title " " }}
{{- $expanded := .open | default false }}
{{- if eq (printf "%T" $expanded) "string" }}
{{- $expanded = (eq $expanded "true") }}
{{- end }}
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context) .id }}
{{- with $context }}
<div class="expand">
<input type="checkbox" id="expand-{{ $id }}" aria-controls="expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}>
<label class="expand-label" for="expand-{{ $id }}" >
<i class="fas fa-chevron-down"></i>
<i class="fas fa-chevron-right"></i>
{{ $title | markdownify }}
</label>
<div id="expandcontent-{{ $id }}" class="expand-content">
{{ $content | safeHTML }}
</div>
</div>
{{- end }}