2023-07-27 14:14:55 +00:00
|
|
|
{{- $page := .page }}
|
|
|
|
{{- if and (not $page) .context }}
|
|
|
|
{{- $page = .context }}
|
2024-09-18 18:47:07 +00:00
|
|
|
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'expand' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/releasenotes/5/#5-18-0" $page.File.Filename }}
|
2023-07-27 14:14:55 +00:00
|
|
|
{{- end }}
|
2024-09-05 18:02:38 +00:00
|
|
|
{{- $content := trim .content "\n\r\t " }}
|
|
|
|
{{- $hasContent := ne (strings.TrimLeft "<p>" $content) "" }}
|
|
|
|
{{- if not (hasPrefix $content "<") }}
|
|
|
|
{{- $content = printf "<p>\n%s" $content }}
|
|
|
|
{{- end }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- $title := .title | default (T "Expand-title") }}
|
2022-12-01 00:37:09 +00:00
|
|
|
{{- $title = trim $title " " }}
|
2024-09-01 11:57:50 +00:00
|
|
|
{{- $expanded := .expanded | default false }}
|
|
|
|
{{- if and (isset . "open") (or (ne (printf "%T" .open) "string") (ne (trim .open " " ) "")) }}
|
2024-09-18 18:47:07 +00:00
|
|
|
{{- warnf "%q: DEPRECATED parameter 'open' for shortcode 'expand' found, use 'expanded' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/releasenotes/6/#6-3-0" $page.File.Filename }}
|
2024-09-01 11:57:50 +00:00
|
|
|
{{- $expanded = .open }}
|
|
|
|
{{- end }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- if eq (printf "%T" $expanded) "string" }}
|
|
|
|
{{- $expanded = (eq $expanded "true") }}
|
|
|
|
{{- end }}
|
2024-08-29 10:28:34 +00:00
|
|
|
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "_relearn/makeRandomMd5.gotmpl" $page) .id }}
|
2023-07-27 14:14:55 +00:00
|
|
|
{{- with $page }}
|
2024-09-05 18:02:38 +00:00
|
|
|
{{- if $hasContent -}}
|
2023-02-03 07:57:55 +00:00
|
|
|
<div class="expand">
|
2024-09-05 18:02:38 +00:00
|
|
|
<input type="checkbox" id="R-expand-{{ $id }}" aria-controls="R-expandcontent-{{ $id }}"{{ if $expanded }} checked{{ end }}>
|
2024-09-01 11:57:50 +00:00
|
|
|
<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">
|
2024-09-05 18:02:38 +00:00
|
|
|
{{ $content | safeHTML }}
|
|
|
|
</div>
|
2022-06-22 18:32:18 +00:00
|
|
|
</div>
|
2024-09-05 18:02:38 +00:00
|
|
|
{{- end }}
|
2022-06-22 18:32:18 +00:00
|
|
|
{{- end }}
|