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:
parent
ac2a619938
commit
59b78300b3
16
.storybook/lib/storiesFromMarkdown.js
Normal file
16
.storybook/lib/storiesFromMarkdown.js
Normal 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))
|
||||
)
|
||||
}, [])
|
||||
}
|
Loading…
Reference in New Issue
Block a user