Auto-generate ID for tabs (#649)

This commit is contained in:
Gram 2024-10-01 22:14:16 +02:00 committed by GitHub
parent b25c58878c
commit 460d44479b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 5 deletions

View File

@ -3,7 +3,7 @@
Tabs let you organize content by context, for example installation instructions for each supported platform.
```tpl
{{</* tabs "uniqueid" */>}}
{{</* tabs */>}}
{{</* tab "MacOS" */>}} # MacOS Content {{</* /tab */>}}
{{</* tab "Linux" */>}} # Linux Content {{</* /tab */>}}
{{</* tab "Windows" */>}} # Windows Content {{</* /tab */>}}
@ -12,7 +12,7 @@ Tabs let you organize content by context, for example installation instructions
## Example
{{< tabs "uniqueid" >}}
{{< tabs >}}
{{< tab "MacOS" >}}
# MacOS

View File

@ -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 }}

View File

@ -1,6 +1,5 @@
{{ if .Inner }}{{ end }}
{{ $id := .Get 0 }}
{{ $group := printf "tabs-%s" $id }}
{{ $group := printf "tabs-%d" .Ordinal }}
<div class="book-tabs">
{{- range $index, $tab := .Scratch.Get $group -}}