|
- import ReactMarkdown from 'react-markdown'
- import { Link } from 'react-router-dom'
-
- type Props = { body: string }
-
-
- export default ({ body }: Props) => (
- <ReactMarkdown components={{ a: (
- ({ href, children }) => (['/', '.'].some (e => href?.startsWith (e))
- ? <Link to={href!}>{children}</Link>
- : <a href={href} target="_blank" rel="noopener noreferrer">{children}</a>)) }}>
- {body}
- </ReactMarkdown>)
|