1
1
mirror of https://github.com/primer/css.git synced 2024-11-23 20:38:58 +03:00
css/docs/markdown.js

29 lines
851 B
JavaScript
Raw Normal View History

2018-12-14 09:29:46 +03:00
import React from 'react'
import {Heading, Link} from '@primer/components'
import CodeExample from './CodeExample'
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,
2019-01-17 01:56:16 +03:00
// render code blocks with our wrapper around mdx-live
code: CodeExample,
// 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>
}
},
2019-01-17 01:56:16 +03:00
// "unwrap" <pre> elements around <code> blocks
pre: props => props.children
}
}