hugo-theme-relearn/layouts/partials/shortcodes/tabs.html

28 lines
1.2 KiB
HTML
Raw Normal View History

{{- $context := .context }}
{{- $tabs := .content | default slice }}
{{- $groupid := .groupid | default (partial "make-random-md5.hugo" $context) }}
{{- with $context }}
<div class="tab-panel cstyle default" data-tab-group="{{ $groupid }}">
<div class="tab-nav">
{{- range $idx, $tab := $tabs }}
<button
data-tab-item="{{ .name | $context.RenderString | plainify }}"
class="tab-nav-button{{ cond (eq $idx 0) " active" ""}}"
onclick="switchTab('{{ $groupid }}','{{ .name | $context.RenderString | plainify}}')"
2023-01-29 15:45:42 +00:00
>
<div><div>{{ .name | $context.RenderString }}</div></div>
</button>
{{- end }}
</div>
<div class="tab-content">
{{- range $idx, $tab := $tabs }}
2023-01-29 15:45:42 +00:00
<div
data-tab-item="{{ .name | $context.RenderString | plainify }}"
class="tab-content-text{{ cond (eq $idx 0) " active" ""}}"
2023-01-29 15:45:42 +00:00
>
{{ if ne "<" (substr (strings.TrimLeft " " .content) 0 1) }}<p>{{ end }}<!-- we add a DOM element here if there is none to make collapsing marings work -->
{{ .content | safeHTML }}</div><!-- no line break allowed here because of awkward behavior of Hugo 110 or this theme when tag shortcode is called standalone outside of tags shortcode ? -->
{{- end }}
</div>
</div>
{{- end }}