Clean up building script a little

This commit is contained in:
Dmitriy Simushev 2015-04-15 10:31:12 +00:00
parent 55014d8507
commit 9c3e1f88c1

122
index.js
View File

@ -5,52 +5,78 @@ var Metalsmith = require('metalsmith'),
navigation = require('metalsmith-navigation'), navigation = require('metalsmith-navigation'),
bower = require('bower'); bower = require('bower');
// Install bower dependencies /**
bower.commands.install([], {}, {}) * Installs bower dependencies that are needed for docs site.
.on('error', function(error) { *
throw error; * @param {Function} callback A function that will be called when the
}) * dependencies are installed.
.on('end', function() { */
// Build the site var installBowerDependencies = function(callback) {
(new Metalsmith(__dirname)) bower.commands.install([], {}, {})
// This data will be available inside the templates .on('error', function(error) {
.metadata({ throw error;
baseUrl: '', })
githubUrl: 'https://github.com/mibew/mibew', .on('end', function() {
// It's documented nowhere but these partials will be passed to if (typeof callback === 'function') {
// Handlebars.js template engine. callback();
partials: { }
// File extension is not skipped here because it will be });
// append automatically using one from rendered file. }
menu: 'menu'
/**
* Builds static HTML pages of the docs site.
*
* @param {Function} callback A function that will be called when the
* pages are built.
*/
var buildPages = function(callback) {
(new Metalsmith(__dirname))
// This data will be available inside the templates
.metadata({
baseUrl: '',
githubUrl: 'https://github.com/mibew/mibew',
// It's documented nowhere but these partials will be passed to
// Handlebars.js template engine.
partials: {
// File extension is not skipped here because it will be
// append automatically using one from rendered file.
menu: 'menu'
}
})
.use(markdown())
.use(navigation(
{
contents: {
sortBy: 'nav_sort',
filterProperty: 'show_in_menu',
includeDirs: true
} }
}) },
.use(markdown()) navSettings = {
.use(navigation( navListProperty: 'navs'
{ }
contents: { ))
sortBy: 'nav_sort', .use(templates({
filterProperty: 'show_in_menu', engine: 'handlebars',
includeDirs: true // The extension cannot be omitted here because it will be used
} // for all partials later.
}, 'default': 'default.handlebars'
navSettings = { }))
navListProperty: 'navs' .use(assets({
} source: './assets',
)) destination: './assets'
.use(templates({ }))
engine: 'handlebars', .build(function(err) {
// The extension cannot be omitted here because it will be used if (err) {
// for all partials later. throw err;
'default': 'default.handlebars' }
})) if (typeof callback === 'function') {
.use(assets({ callback();
source: './assets', }
destination: './assets' });
})) }
.build(function(err) {
if (err) { // Build the site
throw err; installBowerDependencies(function() {
} buildPages();
}); });
});