0.2.2 • Published 10 months ago

remark-read-frontmatter v0.2.2

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

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, default data
    The vfile property name where to find the frontmatter object.
0.2.1

10 months ago

0.2.0

10 months ago

0.2.2

10 months ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.1

3 years ago

0.1.0

3 years ago