docs_vue2/one/build/remark-extract-frontmatter.js

17 lines
345 B
JavaScript
Raw Permalink Normal View History

2020-08-13 11:47:56 +08:00
import visit from 'unist-util-visit'
import remove from 'unist-util-remove'
import yaml from 'js-yaml'
export default function attacher () {
return (tree, file) => {
let { data } = file
visit(tree, 'yaml', node => {
data.meta = yaml.safeLoad(node.value)
return visit.EXIT
})
remove(tree, ['yaml', 'toml'])
}
}