File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
packages/ui-components/src/MDX Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ type MDXCodeTabsProps = {
1010 defaultTab ?: string ;
1111} ;
1212
13+ const NAME_OVERRIDES : Record < string , string | undefined > = {
14+ mjs : 'ESM' ,
15+ } ;
16+
1317const MDXCodeTabs : FC < MDXCodeTabsProps > = ( {
1418 languages : rawLanguages ,
1519 displayNames : rawDisplayNames ,
@@ -20,12 +24,22 @@ const MDXCodeTabs: FC<MDXCodeTabsProps> = ({
2024 const languages = rawLanguages . split ( '|' ) ;
2125 const displayNames = rawDisplayNames ?. split ( '|' ) ?? [ ] ;
2226
27+ const occurrences : Record < string , number > = { } ;
28+
2329 const tabs = languages . map ( ( language , index ) => {
24- const displayName = displayNames [ index ] ;
30+ const base =
31+ displayNames [ index ] ?. trim ( ) ||
32+ NAME_OVERRIDES [ language ] ||
33+ language . toUpperCase ( ) ;
34+
35+ const count = occurrences [ base ] ?? 0 ;
36+ occurrences [ base ] = count + 1 ;
37+
38+ const label = count === 0 ? base : `${ base } (${ count } )` ;
2539
2640 return {
2741 key : `${ language } -${ index } ` ,
28- label : displayName ?. length ? displayName : language . toUpperCase ( ) ,
42+ label : label ,
2943 } ;
3044 } ) ;
3145
You can’t perform that action at this time.
0 commit comments