Skip to content

Commit

Permalink
Removed type check for children in pre
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikmurakonda committed Oct 6, 2023
1 parent 738341b commit 11319e2
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions components/MDX.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function getMDXComponents() {
th: props => <th {...props} className={`${props.className || ''} px-6 py-3 border-b border-gray-200 bg-gray-100 text-left text-xs leading-4 font-medium font-body text-gray-900 uppercase tracking-wider`} />,
tr: props => <tr {...props} className={`${props.className || ''} bg-white`} />,
td: props => <td {...props} className={`${props.className || ''} px-6 py-4 border-b border-gray-200 text-sm leading-5 text-gray-700 tracking-tight`} />,
pre: PreComponent,
pre: props => CodeComponent(props.children.props),
code: props => <code {...props} className={`${props.className || ''} px-1 py-0.5 bg-gray-200 text-gray-800 rounded font-mono text-sm`} />,
hr: props => <hr {...props} className={`${props.className || ''} my-8`} />,
CodeBlock,
Expand Down Expand Up @@ -91,15 +91,6 @@ export function getMDXComponents() {
}
}

function PreComponent(props){
if (props.children && props.children.type.name === 'code'){
return CodeComponent(props.children.props)
}
return (
<div {...props} className={`${props.className || ''} my-8`} />
)
}

function CodeComponent({ children, className = '', metastring = '', ...rest }) {
let caption
const meta = metastring.split(/([\w]+=[\w\d\s\-_:><.]+)/) || []
Expand Down

0 comments on commit 11319e2

Please sign in to comment.