spirit-front-matter

1.0.1 • Public • Published

Spirit Front Matter

Summary

A YAML and JSON front matter middleware for the Spirit Core static file generator. Using the Gray Matter
front matter parser.

Installation

Install from npm.

npm install spirit-front-matter

Syntax

Directory structure

  > = Directory
  - = File

  > "example"
    > "src"
      - matter.txt

In matter.txt file.

---
foo : bar
---

// File Content  
var spiritCore = require( 'spirit-core' ) ;
var spiritFrontMatter = require( 'spirit-front-matter' ) ;

var config = {
  frontMatter : {
    deliminators : [ '---', '---' ]
  }
} ;

var spirit     = new SpiritCore( '.', config ) ;
var spiritData = spirit.getData( ) ;
var spiritFiles = spiritData.files ;

console.log( spiritFiles[ "matter.txt" ] ) ;

Will log the fileData

  {
    buffer : [ Buffer ],
    data : { foo : "bar" } ,
    content : // utf8 encoded file contents
  }

Configuration

Front Matter configuration object should map to the frontMatter key and has the optional values.

config.frontMatter.deliminators : Array

Takes an Array of two Strings that will mark the characters to deliminate the chunk of data to parse. will default to [ "---", "---" ].

Refer to the Grey Matter front matter parser for more information.

Hand made in San Francisco California by Alex Ray .

Readme

Keywords

Package Sidebar

Install

npm i spirit-front-matter

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • alexray