fix(v2): handle case when <code> children is not a string (#1584)

This commit is contained in:
Endi 2019-06-07 22:54:27 +07:00 committed by Yangshun Tay
parent d98b4c50d2
commit 1aa0ea1152

View file

@ -10,7 +10,13 @@ import CodeBlock from '@theme/CodeBlock';
import styles from './styles.module.css';
export default {
code: CodeBlock,
code: props => {
const {children} = props;
if (typeof children === 'string') {
return <CodeBlock {...props} />;
}
return children;
},
a: Link,
pre: props => <pre className={styles.mdxCodeBlock} {...props} />,
};