Created
October 7, 2015 06:14
-
-
Save saintedlama/1e1e6de292f512946db8 to your computer and use it in GitHub Desktop.
Build example with metalsmith
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const Metalsmith = require('metalsmith'); | |
const markdown = require('metalsmith-markdown'); | |
const layouts = require('metalsmith-layouts'); | |
const render = require('metalsmith-in-place'); | |
const collections = require('metalsmith-collections'); | |
const permalinks = require('metalsmith-permalinks'); | |
const branch = require('metalsmith-branch'); | |
const shell = require('shelljs'); | |
function collection(collectionName) { | |
return function(filename, props) { | |
return props && props.collection && props.collection.indexOf(collectionName) >= 0; | |
} | |
} | |
Metalsmith(__dirname) | |
.use(collections({ | |
pages: { | |
pattern: 'pages/*.*' | |
}, | |
rules: { | |
pattern: 'docs/rules/*.*' | |
}, | |
docs : { | |
pattern: 'docs/*.*' | |
} | |
})) | |
.use(markdown()) | |
.use(permalinks({ | |
pattern: ':collection/:title' | |
})) | |
.use(branch(collection('rules')).use(permalinks({ // Special permalink for rules to render rules docs under docs | |
pattern: 'docs/:collection/:title' | |
}))) | |
.use(layouts('handlebars')) | |
.use(render('handlebars')) | |
.destination('./build') | |
.build(function(err, files) { | |
if (err) { throw err; } | |
shell.cp('-rf', 'build/*', '../serve'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment