Move tabs sync setting under page params

This commit is contained in:
Xin
2025-06-08 11:51:57 +01:00
parent cf4d334da3
commit 54032eb238
3 changed files with 10 additions and 22 deletions

View File

@ -17,23 +17,15 @@ next: /docs/guide/deploy-site
Tabs with the same list of `items` can be synchronized. When enabled, selecting a tab updates all other tabs with the same `items` and remembers the selection across pages.
Enable globally in your `hugo.yaml`:
Enable globally in your `hugo.yaml` under the `page` section:
```yaml {filename="hugo.yaml"}
params:
page:
tabs:
sync: true
```
Or enable it for a single page in the front matter:
```yaml {filename="content/docs/my-page.md"}
---
title: My Page
tabsSync: true
---
```
With this enabled the following two tab blocks will always display the same selected item:
```markdown

View File

@ -132,10 +132,6 @@ params:
# link: /
width: wide
page:
# full (100%), wide (90rem), normal (80rem)
width: normal
theme:
# light | dark | system
default: system
@ -184,6 +180,9 @@ params:
# hover | always
display: hover
page:
# full (100%), wide (90rem), normal (80rem)
width: normal
tabs:
sync: true

View File

@ -1,10 +1,7 @@
{{- $items := split (.Get "items") "," -}}
{{- $defaultIndex := int ((.Get "defaultIndex") | default "0") -}}
{{- $enableSync := site.Params.tabs.sync | default false -}}
{{- with .Page.Params.tabsSync }}
{{- $enableSync = . -}}
{{- end -}}
{{- $enableSync := site.Params.page.tabs.sync | default false -}}
{{- if not $items -}}
{{ errorf "no items provided" }}