mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2024-11-22 03:19:25 +00:00
Auto-generate ID for tabs (#649)
This commit is contained in:
parent
b25c58878c
commit
460d44479b
@ -3,7 +3,7 @@
|
|||||||
Tabs let you organize content by context, for example installation instructions for each supported platform.
|
Tabs let you organize content by context, for example installation instructions for each supported platform.
|
||||||
|
|
||||||
```tpl
|
```tpl
|
||||||
{{</* tabs "uniqueid" */>}}
|
{{</* tabs */>}}
|
||||||
{{</* tab "MacOS" */>}} # MacOS Content {{</* /tab */>}}
|
{{</* tab "MacOS" */>}} # MacOS Content {{</* /tab */>}}
|
||||||
{{</* tab "Linux" */>}} # Linux Content {{</* /tab */>}}
|
{{</* tab "Linux" */>}} # Linux Content {{</* /tab */>}}
|
||||||
{{</* tab "Windows" */>}} # Windows Content {{</* /tab */>}}
|
{{</* tab "Windows" */>}} # Windows Content {{</* /tab */>}}
|
||||||
@ -12,7 +12,7 @@ Tabs let you organize content by context, for example installation instructions
|
|||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
{{< tabs "uniqueid" >}}
|
{{< tabs >}}
|
||||||
{{< tab "MacOS" >}}
|
{{< tab "MacOS" >}}
|
||||||
# MacOS
|
# MacOS
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{{ if .Parent }}
|
{{ if .Parent }}
|
||||||
{{ $name := .Get 0 }}
|
{{ $name := .Get 0 }}
|
||||||
{{ $group := printf "tabs-%s" (.Parent.Get 0) }}
|
{{ $group := printf "tabs-%d" .Parent.Ordinal }}
|
||||||
|
|
||||||
{{ if not (.Parent.Scratch.Get $group) }}
|
{{ if not (.Parent.Scratch.Get $group) }}
|
||||||
{{ .Parent.Scratch.Set $group slice }}
|
{{ .Parent.Scratch.Set $group slice }}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{{ if .Inner }}{{ end }}
|
{{ if .Inner }}{{ end }}
|
||||||
{{ $id := .Get 0 }}
|
{{ $group := printf "tabs-%d" .Ordinal }}
|
||||||
{{ $group := printf "tabs-%s" $id }}
|
|
||||||
|
|
||||||
<div class="book-tabs">
|
<div class="book-tabs">
|
||||||
{{- range $index, $tab := .Scratch.Get $group -}}
|
{{- range $index, $tab := .Scratch.Get $group -}}
|
||||||
|
Loading…
Reference in New Issue
Block a user