all repos — caroster @ 3010fd5066be948e41801643efc745089461e26a

[Octree] Group carpool to your event https://caroster.io

frontend/components/Markdown/index.tsx (view raw)

 1import { styled } from '@material-ui/core/styles';
 2import Typography, { TypographyProps } from '@material-ui/core/Typography';
 3import {marked} from 'marked';
 4
 5const Markdown = (props: TypographyProps) => {
 6  const {children, ...typographyProps} = props;
 7
 8  if (!children) return null;
 9
10  return (
11    <Text
12      {...typographyProps}
13      dangerouslySetInnerHTML={{__html: marked(children)}}
14    />
15  );
16};
17
18const Text = styled(Typography)(({theme}) => ({
19  '& > *:first-child': {
20    marginTop: 0,
21  },
22}));
23
24export default Markdown;