feat: 类型声明

This commit is contained in:
Archer
2023-03-10 20:18:31 +08:00
parent 38d49ea05f
commit 7fb76cde0b
5 changed files with 11 additions and 13 deletions

View File

@@ -25,7 +25,8 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean
pre: 'div',
code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || '');
const code = String(children).replace(/\n$/, '');
const code = String(children);
return !inline || match ? (
<Box my={3} borderRadius={'md'} overflow={'hidden'} backgroundColor={'#222'}>
<Flex
@@ -53,7 +54,7 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean
</Box>
) : (
<code className={className} {...props}>
{children}
{code}
</code>
);
}