Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
fix(components): 🐛 fix issue with setting up code block language
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed Jul 3, 2020
1 parent 33f407b commit 98750c7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/MdxComponents/codeBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ const LoadableComponent = Loadable({
});

/* eslint-disable react/jsx-key */
const CodeBlock = ({ children: exampleCode, ...props }) => {
const CodeBlock = ({ children: code, ...props }) => {
if (props['react-live']) {
return <LoadableComponent code={exampleCode} />;
return <LoadableComponent code={code} />;
} else {
const lang = props.className ? props.className.split('-')[1] : null;
return (
<Highlight {...defaultProps} code={exampleCode} language="javascript" theme={theme}>
<Highlight {...defaultProps} code={code} language={lang ? lang : "javascript"} theme={theme}>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className + ' pre'} style={style} p={3}>
{cleanTokens(tokens).map((line, i) => {
Expand Down

0 comments on commit 98750c7

Please sign in to comment.