1.0.2 • Published 10 years ago
spirit-site-data v1.0.2
Spirit Site Data
Summary
A simple template data generator for the Spirit Core static file generator.
Syntax
Install the Spirit Core through npm.
npm install spirit-core.
var config = {
site : {
data : {
title : "A spirit blog.",
description : "Something awesome."
}
}
} ;
var SpiritCore = require( 'spirit-core' ) ;
var spirit = new SpiritCore( ".", config ) ;
var spiritData = spirit.getData( ) ;
var spiritSiteData = spiritData.site ;
console.log( spiritData.site ) ;
/* RETURNS =>
{
title : "A spirit blog",
description : "Something awesome."
}
*/
Properties
spiritData.site
The data object containing all template data
Configuration
There are three ways to pass data into the site property
- Through the Spirit Core configuration files site property.
// In "_config.json"
{
site : {
// put data here
}
}
- Programmatically to the Spirit Core constructor .
var config = {
site : {
// put data here
}
}
var SpiritCore = require( 'spirit-core' ) ;
var spirit = new SpiritCore( '/root/path', config )
- By specifying a src path in the site config
var config = {
site : {
src : 'siteData.json'
}
} ;
var SpiritCore = require( 'spirit-core' ) ;
var spirit = new SpiritCore( 'root/path', config ) ;
/* in "siteData.json"
{
// put data here
}
*/
- By including a
site.json
file in the source directory
/* in "_site.json"
{
// put data here
}
*/
Handmade in San Francisco California by Alex Ray