fix(tabs): improve tab shortcode rendering and restore sticky code header (#772)

* fix(tabs): improve tab shortcode rendering and trim whitespace

* fix(tabs): restore sticky code header for left/right placement
This commit is contained in:
Cell
2026-05-28 12:56:07 +08:00
committed by GitHub
parent 038f602bc5
commit 5b43c2b6a3
5 changed files with 13 additions and 15 deletions
+10 -8
View File
@@ -40,14 +40,16 @@
{{- end -}}
{{- /* Tabs Container */ -}}
<tab-container default-tab="{{ $defaultTab }}" placement="{{ $placement }}"{{ with $type }} type="{{ . }}"{{ end }}>
{{- range $index, $tab := $tabs -}}
{{- $title := $tab.title | default (printf "Untitled%v" $index) -}}
{{- $id := $tab.id -}}
<button class="tab-button" type="button" role="tab" id="tab-{{ $id }}" aria-selected="{{ eq $index $defaultTab }}">{{ $title | $.Page.RenderString }}</button>
{{- end -}}
{{- .Inner -}}
</tab-container>
<div class="shortcode-tabs">
<tab-container default-tab="{{ $defaultTab }}" placement="{{ $placement }}"{{ with $type }} type="{{ . }}"{{ end }}>
{{- range $index, $tab := $tabs -}}
{{- $title := $tab.title | default (printf "Untitled%v" $index) -}}
{{- $id := $tab.id -}}
<button class="tab-button" type="button" role="tab" id="tab-{{ $id }}" aria-selected="{{ eq $index $defaultTab }}">{{ $title | $.Page.RenderString }}</button>
{{- end -}}
{{- .Inner | strings.TrimSpace | .Page.RenderString -}}
</tab-container>
</div>
{{- .Page.Store.Set "hasTabs" true -}}