-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 마크다운 컴포넌트 분리 * feat: 선택지에 마크다운 적용 및 인라인 코드블럭 적용 안되는 문제 수정 * style: 마크다운 내 요소의 margin 조정 * feat: UI 정리 * style: 인라인 코드 블럭 텍스트 색상 변경 * style: 인라인 코드 블럭 양 끝 따옴표 제거 * style: 인라인 코드 블럭 px 조절
- Loading branch information
1 parent
2730c7e
commit fa2e1d6
Showing
4 changed files
with
96 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { cn } from '@/libs/utils'; | ||
import React from 'react'; | ||
import ReactMarkdown from 'react-markdown'; | ||
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; | ||
import { dracula } from 'react-syntax-highlighter/dist/cjs/styles/prism'; | ||
import remarkGfm from 'remark-gfm'; | ||
|
||
interface MarkdownProps extends React.ComponentProps<typeof SyntaxHighlighter> { | ||
className?: string; | ||
} | ||
|
||
export default function MarkDown({ | ||
children, | ||
className, | ||
style = dracula, | ||
...props | ||
}: MarkdownProps) { | ||
return ( | ||
<ReactMarkdown | ||
className={cn('markdown', className)} | ||
remarkPlugins={[remarkGfm]} | ||
components={{ | ||
code({ className, children, ...rest }) { | ||
const language = className?.replace('language-', ''); | ||
|
||
return language ? ( | ||
<SyntaxHighlighter | ||
{...rest} | ||
customStyle={{ padding: '0', overflow: 'hidden' }} | ||
language={language} | ||
style={style} | ||
ref={null} | ||
{...props} | ||
> | ||
{String(children).replace(/\n$/, '')} | ||
</SyntaxHighlighter> | ||
) : ( | ||
<code | ||
{...rest} | ||
className={cn('bg-gray-300 py-1 px-1.5 rounded-md', className)} | ||
style={{ color: '#FF5262' }} | ||
> | ||
{children} | ||
</code> | ||
); | ||
}, | ||
}} | ||
> | ||
{String(children)} | ||
</ReactMarkdown> | ||
); | ||
} |