1.0.3 • Published 8 years ago

@justinc/remark-yaml-meta v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

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.

License

MIT © Chris Gomez