@@ -2,17 +2,8 @@ import { useActiveVersion } from '@docusaurus/plugin-content-docs/client';
22import { useColorMode } from '@docusaurus/theme-common' ;
33import { usePluginData } from '@docusaurus/useGlobalData' ;
44import MDXPre from '@theme-original/MDXComponents/Pre' ;
5- import TabItem from '@theme/TabItem' ;
6- import Tabs from '@theme/Tabs' ;
75import React from 'react' ;
86
9- const SUPPORTED_TABS = {
10- config : [
11- { value : 'static' , label : 'Static' , default : true } ,
12- { value : 'dynamic' , label : 'Dynamic' } ,
13- ] ,
14- } ;
15-
167const COMMENTS = {
178 HIGHLIGHT_START : '// highlight-start' ,
189 HIGHLIGHT_END : '// highlight-end' ,
@@ -26,7 +17,6 @@ export default function Pre({
2617 'data-name' : name ,
2718 'data-snack' : snack ,
2819 'data-dependencies' : deps ,
29- 'data-tabs' : tabs ,
3020 'data-lang' : lang ,
3121 ...rest
3222} ) {
@@ -38,62 +28,6 @@ export default function Pre({
3828
3929 const child = React . Children . only ( children ) ;
4030
41- // If we encounter tabs, we need to render 2 code blocks
42- if ( tabs && tabs in SUPPORTED_TABS ) {
43- return (
44- < Tabs groupId = "config" queryString = "config" >
45- { SUPPORTED_TABS [ tabs ] . map ( ( tab ) => {
46- const code = child . props . children ;
47-
48- if ( typeof code !== 'string' ) {
49- throw new Error (
50- 'Code to display in tabs must be a string, but received ' +
51- typeof code
52- ) ;
53- }
54-
55- const lines = code . split ( '\n' ) ;
56-
57- let content = '' ;
58- let exclude = false ;
59- let indent ;
60-
61- for ( const line of lines ) {
62- if ( line . trim ( ) . startsWith ( '// codeblock-tabs=' ) ) {
63- exclude = line . trim ( ) !== `// codeblock-tabs=${ tab . value } ` ;
64- } else if ( line . trim ( ) === '// codeblock-tabs-end' ) {
65- exclude = false ;
66- } else if ( ! exclude ) {
67- content += line + '\n' ;
68- }
69- }
70-
71- return (
72- < TabItem
73- key = { tab . value }
74- value = { tab . value }
75- label = { tab . label }
76- default = { tab . default }
77- >
78- < Pre
79- { ...rest }
80- data-name = { name }
81- data-snack = { snack }
82- data-dependencies = { deps }
83- data-lang = { lang }
84- >
85- { React . cloneElement ( children , {
86- ...child . props ,
87- children : content . trim ( ) ,
88- } ) }
89- </ Pre >
90- </ TabItem >
91- ) ;
92- } ) }
93- </ Tabs >
94- ) ;
95- }
96-
9731 // Handle diffs with language
9832 if ( child . props . className === 'language-diff' && lang ) {
9933 const code = child . props . children ;
0 commit comments