remark-read-frontmatter
v0.2.2
Published
Parse frontmatter and insert the "data" field in the vfile object.
Downloads
23
Readme
Remark Read Frontmatter
Parse frontmatter and insert the "data" field in the vfile object.
Usage
Place this plugins after remark-frontmatter
and before remark-rehype
.
See example:
const assert = require('assert');
const unified = require('unified');
const parseMarkdown = require('remark-parse');
const remark2rehype = require('remark-rehype');
const html = require('rehype-stringify');
const extractFrontmatter = require('remark-frontmatter');
const pluginParseFrontmatter = require('remark-read-frontmatter');
const {data} = unified()
.use(parseMarkdown)
.use(extractFrontmatter, ['yaml'])
.use(pluginParseFrontmatter)
.use(remark2rehype)
.use(html)
.processSync([
`---`,
`title: 'Article'`,
`lang: fr`,
`---`,
].join('\n'));
// Test output
assert.deepEqual(data, {
title: 'Article',
lang: 'fr'
});
Options
property
, string, defaultdata
The vfile property name where to find the frontmatter object.