From 2cac2bfe4af84178fb2524f6fc3be7eb0d9c0c78 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Fri, 2 Jan 2026 17:27:00 +0800 Subject: [PATCH] feat(tabs): support icon --- layouts/shortcodes/tab.html | 3 ++- layouts/shortcodes/tabs.html | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html index 338ccc52..f2b96f2a 100644 --- a/layouts/shortcodes/tab.html +++ b/layouts/shortcodes/tab.html @@ -1,7 +1,8 @@ {{- $label := .Get "label" -}} +{{- $icon := .Get "icon" -}} {{- $index := .Parent.Store.Get "tab-index" | default 0 -}} {{- $content := .InnerDeindent | strings.TrimSpace | .Page.RenderString -}} {{- $tabs := .Parent.Store.Get "tabs" | default slice -}} -{{- .Parent.Store.Set "tabs" ($tabs | append (dict "label" $label "content" $content)) -}} +{{- .Parent.Store.Set "tabs" ($tabs | append (dict "label" $label "icon" $icon "content" $content)) -}} {{- .Parent.Store.Set "tab-index" (add 1 $index) -}} diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html index 07fe2695..b785f906 100644 --- a/layouts/shortcodes/tabs.html +++ b/layouts/shortcodes/tabs.html @@ -13,7 +13,12 @@ role="tab" aria-selected="{{ cond (eq $nTabs 0) "true" "false" }}" data-tab-index="{{ $nTabs }}"> - {{ index . "label" }} + + {{ with index . "icon" }} + {{ partial "icon.html" . }} + {{ end }} + {{ index . "label" }} + {{- end -}}