Git Product home page Git Product logo

yaml-front-matter-brunch's Introduction

yaml-front-matter-brunch

Verison 0.2.6

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

Installation

In a node project run:

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

Usage

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
categories:
 - food
 - breakfast
---

Bacon
======

Bacon is great! We all like [Bacon](//en.wikipedia.org/wiki/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=\"//en.wikipedia.org/wiki/Bacon\">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);
  listOfPosts.push(post);
});

Questions and Comments

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

yaml-front-matter-brunch's People

Stargazers

Aaron Strick avatar Johnathan Gilday avatar Matthew McLeod avatar

Watchers

James Cloos avatar Duncan Walker avatar

Forkers

strickinato

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.