mirror of
https://github.com/Mibew/docs.mibew.org.git
synced 2025-04-20 10:07:23 +03:00
Clean up building script a little
This commit is contained in:
parent
55014d8507
commit
9c3e1f88c1
122
index.js
122
index.js
@ -5,52 +5,78 @@ var Metalsmith = require('metalsmith'),
|
||||
navigation = require('metalsmith-navigation'),
|
||||
bower = require('bower');
|
||||
|
||||
// Install bower dependencies
|
||||
bower.commands.install([], {}, {})
|
||||
.on('error', function(error) {
|
||||
throw error;
|
||||
})
|
||||
.on('end', function() {
|
||||
// Build the site
|
||||
(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'
|
||||
/**
|
||||
* Installs bower dependencies that are needed for docs site.
|
||||
*
|
||||
* @param {Function} callback A function that will be called when the
|
||||
* dependencies are installed.
|
||||
*/
|
||||
var installBowerDependencies = function(callback) {
|
||||
bower.commands.install([], {}, {})
|
||||
.on('error', function(error) {
|
||||
throw error;
|
||||
})
|
||||
.on('end', function() {
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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())
|
||||
.use(navigation(
|
||||
{
|
||||
contents: {
|
||||
sortBy: 'nav_sort',
|
||||
filterProperty: 'show_in_menu',
|
||||
includeDirs: true
|
||||
}
|
||||
},
|
||||
navSettings = {
|
||||
navListProperty: 'navs'
|
||||
}
|
||||
))
|
||||
.use(templates({
|
||||
engine: 'handlebars',
|
||||
// The extension cannot be omitted here because it will be used
|
||||
// for all partials later.
|
||||
'default': 'default.handlebars'
|
||||
}))
|
||||
.use(assets({
|
||||
source: './assets',
|
||||
destination: './assets'
|
||||
}))
|
||||
.build(function(err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
navSettings = {
|
||||
navListProperty: 'navs'
|
||||
}
|
||||
))
|
||||
.use(templates({
|
||||
engine: 'handlebars',
|
||||
// The extension cannot be omitted here because it will be used
|
||||
// for all partials later.
|
||||
'default': 'default.handlebars'
|
||||
}))
|
||||
.use(assets({
|
||||
source: './assets',
|
||||
destination: './assets'
|
||||
}))
|
||||
.build(function(err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Build the site
|
||||
installBowerDependencies(function() {
|
||||
buildPages();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user