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

add markdown story parser

This commit is contained in:
Shawn Allen 2017-09-12 16:43:34 -07:00
parent ac2a619938
commit 59b78300b3

View File

@ -0,0 +1,16 @@
import remark from 'remark'
import select from 'unist-util-select'
import htmlToReact from 'html-to-react'
export default req => {
const parser = new htmlToReact.Parser()
return req.keys()
.reduce((stories, file) => {
const content = req(file)
const ast = remark.parse(content)
return stories.concat(
select(ast, 'code[lang^=html]')
.map(node => parser.parse(node.value))
)
}, [])
}