Skip to content

Commit

Permalink
ReferenceCodeBlock workaround fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gtnardy committed Oct 7, 2024
1 parent 63be863 commit 9a721eb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/theme/CodeBlock/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import CodeBlock from '@theme-original/CodeBlock';
import type CodeBlockType from '@theme/CodeBlock';
import type {WrapperProps} from '@docusaurus/types';
import ReferenceCodeBlock from '@saucelabs/theme-github-codeblock/build/theme/ReferenceCodeBlock';

type Props = WrapperProps<typeof CodeBlockType>;

export default function CodeBlockWrapper(props: Props): JSX.Element {
// Fixes props.metastring parsing
if (props.metastring?.split(' ').includes('reference')) {
return (
<ReferenceCodeBlock {...props} />
);
}

// Native CodeBlock
return (
<>
<CodeBlock {...props} />
</>
);
}

0 comments on commit 9a721eb

Please sign in to comment.