From 460d44479b5a8c6b6a114748c5abafcc56036e57 Mon Sep 17 00:00:00 2001 From: Gram Date: Tue, 1 Oct 2024 22:14:16 +0200 Subject: [PATCH] Auto-generate ID for tabs (#649) --- exampleSite/content.en/docs/shortcodes/tabs.md | 4 ++-- layouts/shortcodes/tab.html | 2 +- layouts/shortcodes/tabs.html | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/exampleSite/content.en/docs/shortcodes/tabs.md b/exampleSite/content.en/docs/shortcodes/tabs.md index 096892c..8a9ad5e 100644 --- a/exampleSite/content.en/docs/shortcodes/tabs.md +++ b/exampleSite/content.en/docs/shortcodes/tabs.md @@ -3,7 +3,7 @@ Tabs let you organize content by context, for example installation instructions for each supported platform. ```tpl -{{}} +{{}} {{}} # MacOS Content {{}} {{}} # Linux Content {{}} {{}} # Windows Content {{}} @@ -12,7 +12,7 @@ Tabs let you organize content by context, for example installation instructions ## Example -{{< tabs "uniqueid" >}} +{{< tabs >}} {{< tab "MacOS" >}} # MacOS diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html index e2a207c..15456d5 100644 --- a/layouts/shortcodes/tab.html +++ b/layouts/shortcodes/tab.html @@ -1,6 +1,6 @@ {{ if .Parent }} {{ $name := .Get 0 }} - {{ $group := printf "tabs-%s" (.Parent.Get 0) }} + {{ $group := printf "tabs-%d" .Parent.Ordinal }} {{ if not (.Parent.Scratch.Get $group) }} {{ .Parent.Scratch.Set $group slice }} diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html index b28eadf..4960d30 100644 --- a/layouts/shortcodes/tabs.html +++ b/layouts/shortcodes/tabs.html @@ -1,6 +1,5 @@ {{ if .Inner }}{{ end }} -{{ $id := .Get 0 }} -{{ $group := printf "tabs-%s" $id }} +{{ $group := printf "tabs-%d" .Ordinal }}
{{- range $index, $tab := .Scratch.Get $group -}}