1
1
mirror of https://github.com/primer/css.git synced 2024-11-28 04:43:05 +03:00
css/docs/markdown.js
2019-04-24 14:35:00 -07:00

30 lines
920 B
JavaScript

import React from 'react'
import {Heading, Link} from '@primer/components'
import {CodeExample} from '@primer/blueprints/dist/next-components-index.umd.js'
import Outline from './Outline'
export const H1 = props => <Heading fontSize={6} fontWeight="light" {...props} />
export default function getComponents(page = {}) {
const {outline: getOutline = () => []} = page
return {
h1: H1,
// render links with our component
a: Link,
// render code blocks with our wrapper around react-live
code: (props) => <CodeExample {...props}/>,
// render the outline for <p> tags with exactly the text "{:toc}"
p: ({children, ...rest}) => {
if (children === '{:toc}') {
return <Outline outline={getOutline()} {...rest} />
} else {
return <p {...rest}>{children}</p>
}
},
// "unwrap" <pre> elements around <code> blocks
pre: props => props.children
}
}