mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-30 11:13:06 +00:00
35 lines
No EOL
1.6 KiB
HTML
35 lines
No EOL
1.6 KiB
HTML
{{- $page := .page }}
|
|
{{- if and (not $page) .context }}
|
|
{{- $page = .context }}
|
|
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'expand' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }}
|
|
{{- end }}
|
|
{{- $content := trim .content "\n\r\t " }}
|
|
{{- $hasContent := ne (strings.TrimLeft "<p>" $content) "" }}
|
|
{{- if not (hasPrefix $content "<") }}
|
|
{{- $content = printf "<p>\n%s" $content }}
|
|
{{- end }}
|
|
{{- $title := .title | default (T "Expand-title") }}
|
|
{{- $title = trim $title " " }}
|
|
{{- $expanded := .expanded | default false }}
|
|
{{- if and (isset . "open") (or (ne (printf "%T" .open) "string") (ne (trim .open " " ) "")) }}
|
|
{{- warnf "%q: DEPRECATED parameter 'open' for shortcode 'expand' found, use 'expanded' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#630" $page.File.Filename }}
|
|
{{- $expanded = .open }}
|
|
{{- end }}
|
|
{{- if eq (printf "%T" $expanded) "string" }}
|
|
{{- $expanded = (eq $expanded "true") }}
|
|
{{- end }}
|
|
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $page) .id }}
|
|
{{- with $page }}
|
|
{{- if $hasContent -}}
|
|
<div class="expand">
|
|
<input type="checkbox" id="R-expand-{{ $id }}" aria-controls="R-expandcontent-{{ $id }}"{{ if $expanded }} checked{{ end }}>
|
|
<label class="expand-label" for="R-expand-{{ $id }}">
|
|
<i class="expander-icon fa-fw fas fa-chevron-down"></i>
|
|
<i class="expander-icon fa-fw fas fa-chevron-right"></i> {{ $title | .RenderString }}
|
|
</label>
|
|
<div id="R-expandcontent-{{ $id }}" class="expand-content">
|
|
{{ $content | safeHTML }}
|
|
</div>
|
|
</div>
|
|
{{- end }}
|
|
{{- end }} |