Skip to content

Commit

Permalink
Auto-generate ID for tabs (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinium authored Oct 1, 2024
1 parent b25c588 commit 460d444
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions exampleSite/content.en/docs/shortcodes/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 */>}}
Expand All @@ -12,7 +12,7 @@ Tabs let you organize content by context, for example installation instructions

## Example

{{< tabs "uniqueid" >}}
{{< tabs >}}
{{< tab "MacOS" >}}
# MacOS

Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/tab.html
Original file line number Diff line number Diff line change
@@ -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 }}
Expand Down
3 changes: 1 addition & 2 deletions layouts/shortcodes/tabs.html
Original file line number Diff line number Diff line change
@@ -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 -}}
Expand Down

0 comments on commit 460d444

Please sign in to comment.