diff --git a/src/components/MDXComponents.tsx b/src/components/MDXComponents.tsx
index 1694ad0889..76f2bd2c4c 100644
--- a/src/components/MDXComponents.tsx
+++ b/src/components/MDXComponents.tsx
@@ -1,7 +1,7 @@
import { Flex, Heading, Link, Stack, Table, Text } from '@chakra-ui/react';
import NextLink from 'next/link';
-import { Code } from './UI/docs'
+import { Code } from './UI/docs';
import { textStyles } from '../theme/foundations';
const { header1, header2, header3, header4 } = textStyles;
@@ -75,15 +75,13 @@ const MDXComponents = {
),
// pre
- pre: ({ children }: any) => {
- return (
-
- {children}
-
- );
- },
+ pre: ({ children }: any) => (
+
+ {children}
+
+ ),
// code
- code: Code
+ code: ({ children, ...props }: any) => {children}
};
export default MDXComponents;
diff --git a/src/components/UI/docs/Code.tsx b/src/components/UI/docs/Code.tsx
index 1ccb3a671e..67768ab44a 100644
--- a/src/components/UI/docs/Code.tsx
+++ b/src/components/UI/docs/Code.tsx
@@ -32,17 +32,17 @@ SyntaxHighlighter.registerLanguage('sh', sh);
SyntaxHighlighter.registerLanguage('solidity', solidity);
SyntaxHighlighter.registerLanguage('swift', swift);
-
interface Props {
- className: string
- children: React.ReactNode
- [key: string]: any
+ className: string;
+ children: string[];
+ inline?: boolean;
}
-export const Code: React.FC = ({ className, children, ...code }: any) => {
+export const Code: React.FC = ({ className, children, inline }) => {
const { colorMode } = useColorMode();
const isDark = colorMode === 'dark';
- const isTerminal = className?.includes('terminal') ;
- if (code.inline)
+ const isTerminal = className?.includes('terminal');
+ const [content] = children;
+ if (inline)
return (
= ({ className, children, ...code }: any) =>
borderRadius='0.25em'
textStyle='inline-code-snippet'
>
- {children[0]}
+ {content}
);
if (isTerminal)
- return (
-
-
- {children[0]}
-
-
- );
+ return (
+
+
+ {content}
+
+
+ );
if (className?.startsWith(CLASSNAME_PREFIX))
return (
= ({ className, children, ...code }: any) =>
style={isDark ? nightOwl : prism}
customStyle={{ borderRadius: '0.5rem', padding: '1rem' }}
>
- {children}
+ {content}
);
- return {children[0]};
+ return {content};
};