diff --git a/components/MDX.js b/components/MDX.js index d8cc79bf90e..6d0e0c0761b 100644 --- a/components/MDX.js +++ b/components/MDX.js @@ -60,7 +60,7 @@ export function getMDXComponents() { th: props => , tr: props => , td: props => , - pre: CodeComponent, + pre: PreComponent, code: props => , hr: props =>
, CodeBlock, @@ -91,11 +91,16 @@ export function getMDXComponents() { } } -function CodeComponent({ children, className, ...rest }) { - if (!children || !children.props || !children.type || children.type.name !== 'code') return
-  let metastring = children.props.metastring || ''
-  className= children.props.className || ''
-  children = children.props.children
+function PreComponent(props){
+  if (props.children && props.children.type.name === 'code'){
+    return CodeComponent(props.children.props)
+  }
+  return (
+    
+ ) +} + +function CodeComponent({ children, className = '', metastring = '', ...rest }) { let caption const meta = metastring.split(/([\w]+=[\w\d\s\-_:><.]+)/) || [] meta.forEach(str => {