0.1.1 • Published 8 years ago

expressful-content v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Expressful content

Give JSON and CSON superpowers for content management

$ npm install expressful-content --save

Quick start

Expressful content makes it easy to use a flat file based content system. You can use this to move your content out of your views. This makes it easy to plugin a flat file CMS.

// app.js
const parseFile = require('expressful-content').parseFile;
const path = require('path');

const CONTENT_DIRECTORY = path.join(__dirname, '/content/');

parseFile(CONTENT_DIRECTORY, 'homepage.cson');

Returns:

{
  title: 'Homepage',
  brandName: 'Expressful content',
  posts: [{ title: 'My first article'}, { title: 'My second article' }]
}

Given the following structure:

.
|-- /app.js
|-- /content
|   |-- /homepage.cson
|   |-- /global.json
|   |-- /blog
|       |-- 2016__07__10__first-article.cson
|       |-- 2016__07__11__second-article.cson

./content/homepage.cson

title: "Homepage"

__extend: "global.cson",

__list:
  directory: 'blog',
  as: 'posts'

global.json

{
  "brandName": "Expressful content"
}

20160710__first-article.cson

title: "My first article"

20160711__second-article.cson.cson

title: "My second article"