From f8a0e8976bd99631e626991eb747c8fbde57dcf2 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Tue, 8 Oct 2024 15:49:39 +0200 Subject: [PATCH] Rewrite tabs shortcode to make them simpler --- layouts/shortcodes/tab.html | 21 +++++++++------------ layouts/shortcodes/tabs.html | 13 +------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html index 15456d59..df424284 100644 --- a/layouts/shortcodes/tab.html +++ b/layouts/shortcodes/tab.html @@ -1,12 +1,9 @@ -{{ if .Parent }} - {{ $name := .Get 0 }} - {{ $group := printf "tabs-%d" .Parent.Ordinal }} - - {{ if not (.Parent.Scratch.Get $group) }} - {{ .Parent.Scratch.Set $group slice }} - {{ end }} - - {{ .Parent.Scratch.Add $group (dict "Name" $name "Content" .Inner) }} -{{ else }} - {{ errorf "%q: 'tab' shortcode must be inside 'tabs' shortcode" .Page.Path }} -{{ end}} +{{- $group := printf "tabs-%d" .Parent.Ordinal -}} +{{- $tab := printf "%s-%d" $group .Ordinal }} + + +
+ {{- .Inner -}} +
diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html index 8f2dd33d..fecbbebf 100644 --- a/layouts/shortcodes/tabs.html +++ b/layouts/shortcodes/tabs.html @@ -1,14 +1,3 @@ -{{- if .Inner }}{{ end -}} -{{- $group := printf "tabs-%d" .Ordinal -}} -
-{{- range $index, $tab := .Scratch.Get $group -}} - - -
- {{- .Content | safeHTML -}} -
-{{- end -}} +{{ .Inner }}