2025-08-15 03:09:58 +02:00
|
|
|
{{- /*
|
|
|
|
Create a tabbed interface with the given items.
|
|
|
|
|
2025-09-11 00:54:27 +02:00
|
|
|
@example {{< tabs >}}...{{< /tabs >}}
|
2025-08-15 03:09:58 +02:00
|
|
|
*/ -}}
|
|
|
|
|
2025-09-11 00:54:27 +02:00
|
|
|
{{- /* Unused, but required for the shortcode to work. */ -}}
|
|
|
|
{{- .Inner -}}
|
2025-07-21 21:16:44 +01:00
|
|
|
|
2025-09-11 00:54:27 +02:00
|
|
|
{{- /* Enable syncing of tabs across the page. */ -}}
|
|
|
|
{{- $enableSync := false -}}
|
|
|
|
{{- if or (eq .Page.Params.tabs.sync false) (eq .Page.Params.tabs.sync true) -}}
|
|
|
|
{{- $enableSync = .Page.Params.tabs.sync -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $enableSync = site.Params.page.tabs.sync | default false -}}
|
2025-07-21 21:16:44 +01:00
|
|
|
{{- end -}}
|
|
|
|
|
2025-09-11 00:54:27 +02:00
|
|
|
{{- $tabs := ($.Store.Get "tabs") | default slice -}}
|
|
|
|
|
|
|
|
{{- /* Compatibility with previous parameter "items". */ -}}
|
|
|
|
{{- if .Get "defaultIndex" -}}
|
|
|
|
{{- warnf "The 'defaultIndex' parameter of the 'tabs' shortcode is deprecated. Please use 'selected' on 'tab' instead." -}}
|
2025-07-21 21:16:44 +01:00
|
|
|
{{- end -}}
|
|
|
|
|
2025-09-11 00:54:27 +02:00
|
|
|
{{- if .Get "items" -}}
|
|
|
|
{{- warnf "The 'items' parameter of the 'tabs' shortcode is deprecated. Please use 'name' on 'tab' instead." -}}
|
|
|
|
|
|
|
|
{{- $items := split (.Get "items") "," -}}
|
|
|
|
|
|
|
|
{{- $temp := slice -}}
|
|
|
|
{{- range $i, $item := $items -}}
|
|
|
|
{{- $tab := index $tabs $i -}}
|
|
|
|
{{- $temp = $temp | append (merge $tab (dict "name" $item)) -}}
|
2025-07-21 21:16:44 +01:00
|
|
|
{{- end -}}
|
2025-09-11 00:54:27 +02:00
|
|
|
|
|
|
|
{{- $tabs = $temp -}}
|
2023-08-02 21:24:52 +01:00
|
|
|
{{- end -}}
|
|
|
|
|
2025-09-11 00:54:27 +02:00
|
|
|
{{- partial "shortcodes/tabs" (dict "tabs" $tabs "enableSync" $enableSync "id" .Ordinal) -}}
|