From 54032eb23895591b4617c5bd426c748fe5c50498 Mon Sep 17 00:00:00 2001 From: Xin <5097752+imfing@users.noreply.github.com> Date: Sun, 8 Jun 2025 11:51:57 +0100 Subject: [PATCH] Move tabs sync setting under page params --- .../content/docs/guide/shortcodes/tabs.md | 16 ++++------------ exampleSite/hugo.yaml | 11 +++++------ layouts/_shortcodes/tabs.html | 5 +---- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/exampleSite/content/docs/guide/shortcodes/tabs.md b/exampleSite/content/docs/guide/shortcodes/tabs.md index df0d493..4c62744 100644 --- a/exampleSite/content/docs/guide/shortcodes/tabs.md +++ b/exampleSite/content/docs/guide/shortcodes/tabs.md @@ -17,21 +17,13 @@ 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: - 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 ---- + page: + tabs: + sync: true ``` With this enabled the following two tab blocks will always display the same selected item: diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index f0e43cf..c0d0c98 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -132,10 +132,6 @@ params: # link: / width: wide - page: - # full (100%), wide (90rem), normal (80rem) - width: normal - theme: # light | dark | system default: system @@ -184,8 +180,11 @@ params: # hover | always display: hover - tabs: - sync: true + page: + # full (100%), wide (90rem), normal (80rem) + width: normal + tabs: + sync: true comments: enable: false diff --git a/layouts/_shortcodes/tabs.html b/layouts/_shortcodes/tabs.html index e0dfb6b..e2405fb 100644 --- a/layouts/_shortcodes/tabs.html +++ b/layouts/_shortcodes/tabs.html @@ -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" }}