Files
actual/node_modules/@docusaurus/theme-classic/lib/theme/MDXComponents/Code.js
Rich In SQL 28d4ee94dd Init
2022-10-16 20:28:33 +01:00

29 lines
752 B
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, {isValidElement} from 'react';
import CodeBlock from '@theme/CodeBlock';
export default function MDXCode(props) {
const inlineElements = [
'a',
'b',
'big',
'i',
'span',
'em',
'strong',
'sup',
'sub',
'small',
];
const shouldBeInline = React.Children.toArray(props.children).every(
(el) =>
(typeof el === 'string' && !el.includes('\n')) ||
(isValidElement(el) && inlineElements.includes(el.props?.mdxType)),
);
return shouldBeInline ? <code {...props} /> : <CodeBlock {...props} />;
}