node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »



Verison 0.2.6

This Brunch plugin compiles markdown files with YAML front matter into javascript objects.


In a node project run:

npm install yaml-front-matter-brunch --save


This Brunch plugin takes a markdown file like this this...

title: I like Bacon
description: Bacon is great - let me tell you why I like it.
published: 2014-04-15
author: Dave
 - food
 - breakfast
Bacon is great! We all like [Bacon](//

... And compiles it into an object like this...

module.exports = {"title":"I like Bacon","description":"Bacon is great - let me tell you why I like it.","published":"2014-04-15T00:00:00.000Z","author":"Dave","categories":["food","breakfast"],"__content":"<h1>Bacon</h1><p>Bacon is great! We all like <a href=\"//\">Bacon</a>"}

Essentially, the file content is overwritten with the javascript object.

Despite still being a .md file, The module is made acessible to the rest of the app based on its filename.

For example, if you are watching a bunch of .md files in a posts directory, you can find and use all the post objects in your Brunch app like this:

var listOfPosts = [];
window.require.list().filter(function(module) {
  return new RegExp('^posts/').test(module);
}).forEach(function(module) {
  var post = require(module);

Questions and Comments

Open an issue, fork and PR, or tweet @Sir_Dunxalot