@justinc/remark-yaml-meta
v1.0.3
Published
Extract YAML front-matter from markdown.
Downloads
6
Maintainers
Readme
remark-yaml-meta
Extract YAML front-matter from markdown.
Installation
npm:
npm install @justinc/remark-yaml-meta
Usage
Dependencies:
var remark = require('remark');
var metaPlugin = require('@justinc/remark-yaml-meta');
var report = require('vfile-reporter');
Process:
remark()
.use(metaPlugin)
.process([
'---',
'foo:',
' bar: true',
'---',
''
].join('\n'), function (err, file) {
// handle error with `vfile-reporter` to show messages
console.error(report(err || file));
// file.meta now has the parsed YAML as an Object
console.log(file.meta) // { foo: { bar: true } }
})
API
remark.use(yamlConfig)
Passes the configuration at the remark
field as parse
and stringify settings.
Just like remark-yaml-config, but the parsed object
is saved to the meta
property of the retuned VFile
.