Skip to content

Instantly share code, notes, and snippets.

@luisalima
Last active July 7, 2016 15:52
Show Gist options
  • Save luisalima/d2b1d58214c63aaec72636a2ccd2ee48 to your computer and use it in GitHub Desktop.
Save luisalima/d2b1d58214c63aaec72636a2ccd2ee48 to your computer and use it in GitHub Desktop.
Metalsmith step-by-step
Use `log` from handlebars v3 onwards:
http://stackoverflow.com/a/32218903
/* pre-setup for this file:
npm init
npm install metalsmith --save-dev
edit index.js and add the code below:
*/
var Metalsmith = require('metalsmith');
Metalsmith(__dirname) // src by default
.destination('./build')
.build(function(err) {
if(err) throw err;
console.log('Build finished');
})
/* test:
Edit src/index.md and add:
## Hello, world!
Testing 1 2 3
Run
node index.js
Output:
You should see index.md, as is, inside build/
*/
/*
Now we are going to transform our markdown into html
Pre-setup:
npm install metalsmith-markdown --save-dev
*/
/* pre-setup for this file:
npm init
npm install metalsmith --save-dev
edit index.js and add the code below:
*/
var Metalsmith = require('metalsmith');
Metalsmith(__dirname) // src by default
.destination('./build')
.use(markdown())
.build(function(err) {
if(err) throw err;
console.log('Build finished');
})
/* test:
Edit src/index.md and add:
## Hello, world!
Testing 1 2 3
Run
node index.js
Output:
You should see index.html, correctly parsed, inside build/
*/
Metalsmith(__dirname)
.destination('./build')
.use(markdown())
.use(layouts({
engine: 'handlebars',
directory: 'layouts'
}))
.build(function(err) {
if(err) throw err;
console.log('Build finished');
});
function myLogger(files, metalsmith, done) {
console.log('Files: ');
console.log(files);
console.log('\nMetalsmith: ');
console.log(metalsmith);
done();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment