From 8db96d108fe587cc49fcaa15b3a3495f362f302d Mon Sep 17 00:00:00 2001 From: maximus Date: Tue, 11 Oct 2022 14:39:45 +0300 Subject: [PATCH] return markdown component --- src/components/Markdown.tsx | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/components/Markdown.tsx diff --git a/src/components/Markdown.tsx b/src/components/Markdown.tsx new file mode 100644 index 0000000..5c5e4b9 --- /dev/null +++ b/src/components/Markdown.tsx @@ -0,0 +1,69 @@ +import React from "react"; + +/* -------------------------------------------------------------------------- */ +/* MarkDown */ +/* -------------------------------------------------------------------------- */ +import ReactMarkdown from "react-markdown"; +import remarkGfm from "remark-gfm"; + +/* -------------------------------------------------------------------------- */ +/* Components */ +/* -------------------------------------------------------------------------- */ +import Typography from "./typography/Typography"; +import Heading from "./typography/Heading"; +import Link from "./Link"; + +/* -------------------------------------------------------------------------- */ +/* Code */ +/* -------------------------------------------------------------------------- */ +import vsc from "react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus"; +import { darcula } from "react-syntax-highlighter/dist/esm/styles/prism"; +import docco from "react-syntax-highlighter/dist/esm/styles/prism"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; + +export type Props = { + markdown: string; +}; + +const Markdown = ({ markdown }: Props) => { + return ( + { + return ( + + {props.children} + + ); + }, + + code({ node, inline, className, children, ...props }) { + const match = /language-(\w+)/.exec(className || ""); + return !inline && match ? ( + + ) : ( + + {children} + + ); + }, + }} + /> + ); +}; + +export default Markdown;