Skip to content

gnowoel/frontmatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

frontmatter Build Status

Parsing YAML frontmatter from a string.

Installation

$ npm install frontmatter

Usage

To parse the content of a string:

var frontmatter = require('frontmatter');
var parsed = frontmatter(content);

As in Jekyll, the YAML frontmatter should be delimited with triple-dash lines and defined at the beginning. For example:

---
title: Welcome
---

Hello!

In this case, the parsed object would be:

{
  "data": {
    "title": "Welcome"
  },
  "content": "\nHello!\n"
}

Use the safeLoad option for untrusted source:

frontmatter(content, { safeLoad: true });

Tests

$ npm install
$ npm test

License

MIT

About

A simple YAML frontmatter parser.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published