File tree Expand file tree Collapse file tree
packages/rehype-shiki/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import AlertBox from '@node-core/ui-components/Common/AlertBox';
44import BadgeGroup from '@node-core/ui-components/Common/BadgeGroup' ;
55import Blockquote from '@node-core/ui-components/Common/Blockquote' ;
66import MDXCodeTabs from '@node-core/ui-components/MDX/CodeTabs' ;
7+ import CodeTabsWithHash from '@node-core/ui-components/MDX/CodeTabs/CodeTabsWithHash' ;
78import {
89 MDXTooltip ,
910 MDXTooltipContent ,
@@ -58,6 +59,7 @@ export default {
5859 AlertBox,
5960 // Renders MDX CodeTabs
6061 CodeTabs : MDXCodeTabs ,
62+ CodeTabsWithHash,
6163 // Renders Tooltips
6264 MDXTooltip,
6365 MDXTooltipContent,
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ export default async function rehypeShikiji(options) {
6767 const codeTabsChildren = [ ] ;
6868
6969 let defaultTab = '0' ;
70+ let groupId ;
7071 let currentIndex = index ;
7172
7273 while ( isCodeBlock ( parent ?. children [ currentIndex ] ) ) {
@@ -84,6 +85,11 @@ export default async function rehypeShikiji(options) {
8485 // Map the display names of each variant for the CodeTab
8586 displayNames . push ( meta . displayName ?. replaceAll ( '|' , '' ) ?? '' ) ;
8687
88+ // Extract groupId if it exists
89+ if ( meta . groupId ) {
90+ groupId = meta . groupId ;
91+ }
92+
8793 codeTabsChildren . push ( parent ?. children [ currentIndex ] ) ;
8894
8995 // If `active="true"` is provided in a CodeBox
@@ -102,12 +108,13 @@ export default async function rehypeShikiji(options) {
102108 if ( codeTabsChildren . length >= 2 ) {
103109 const codeTabElement = {
104110 type : 'element' ,
105- tagName : 'CodeTabs' ,
111+ tagName : groupId ? 'CodeTabsWithHash' : 'CodeTabs' ,
106112 children : codeTabsChildren ,
107113 properties : {
108114 languages : languages . join ( '|' ) ,
109115 displayNames : displayNames . join ( '|' ) ,
110116 defaultTab,
117+ groupId,
111118 } ,
112119 } ;
113120
You can’t perform that action at this time.
0 commit comments