Reactive-Resume/client/components/shared/Markdown.tsx

22 lines
490 B
TypeScript
Raw Normal View History

2022-03-02 16:44:11 +00:00
import clsx from 'clsx';
2022-03-06 21:48:29 +00:00
import { isEmpty } from 'lodash';
2022-03-02 16:44:11 +00:00
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
type Props = {
children?: string;
className?: string;
};
const Markdown: React.FC<Props> = ({ className, children }) => {
2022-03-06 21:48:29 +00:00
if (!children || isEmpty(children)) return null;
2022-03-02 16:44:11 +00:00
return (
<ReactMarkdown remarkPlugins={[remarkGfm]} className={clsx('markdown', className)}>
{children}
</ReactMarkdown>
);
};
export default Markdown;