Skip to content

Commit 2fca904

Browse files
committed
Update TabbedCode.jsx
1 parent 4331890 commit 2fca904

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

resources/js/Components/TabbedCode.jsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,20 @@ const guessTabType = tabNames => {
1616
const TabbedCode = ({ className, examples, height }) => {
1717
const [codeTabs, setCodeTabs] = useContext(CodeTabContext) || useState({ unknown: 0 })
1818
const tabType = guessTabType(examples.map(example => example.name))
19-
const exampleIndex = examples.findIndex(example => codeTabs[tabType] === example.name)
20-
const activeTab = exampleIndex < 0 ? (examples.length - 1) : exampleIndex
19+
const exampleIndex = examples.findIndex(example => {
20+
if (codeTabs[tabType] === example.name) {
21+
return true
22+
}
23+
24+
if (
25+
(codeTabs[tabType]?.startsWith('Svelte') && example.name === 'Svelte') ||
26+
(codeTabs[tabType] === 'Svelte' && example.name.startsWith('Svelte'))
27+
) {
28+
// Svelte example are named either 'Svelte', 'Svelte 4', or 'Svelte 5'
29+
return true
30+
}
31+
})
32+
const activeTab = exampleIndex < 0 ? 0 : exampleIndex
2133

2234
return (
2335
<div className={className || 'my-8 overflow-hidden rounded'}>

0 commit comments

Comments
 (0)