Skip to content

Commit 196e5b8

Browse files
committed
fix package manager tabs for single-framework posts
Fall back to the first available framework so package manager tabs still render when a page only defines one framework.
1 parent b1931cf commit 196e5b8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/components/markdown/PackageManagerTabs.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ export function PackageManagerTabs({
5252
'react') as Framework
5353

5454
const normalizedFramework = actualFramework.toLowerCase()
55-
const packageGroups = packagesByFramework[normalizedFramework]
55+
const fallbackFramework = Object.keys(packagesByFramework).find(
56+
(framework) => packagesByFramework[framework]?.length,
57+
)
58+
const packageGroups =
59+
packagesByFramework[normalizedFramework] ||
60+
(fallbackFramework ? packagesByFramework[fallbackFramework] : undefined)
5661

57-
// Hide component if current framework not in package list
62+
// Fall back to the first available framework so single-framework content still renders.
5863
if (!packageGroups || packageGroups.length === 0) {
5964
return null
6065
}

0 commit comments

Comments
 (0)