UNPKG

973 BJavaScriptView Raw
1var koa = require('koa'),
2 serve = require('koa-static'),
3 metalsmith = require('metalsmith'),
4 markdown = require('metalsmith-markdown'),
5 templates = require('metalsmith-templates'),
6 collections = require('metalsmith-collections'),
7 permalinks = require('metalsmith-permalinks'),
8 beautify = require('metalsmith-beautify'),
9 moment = require('moment');
10
11app = koa();
12
13metalsmith(__dirname)
14 .use(markdown())
15 .use(collections({
16 blog: {
17 pattern: './blog/*.md',
18 sortBy: 'date',
19 reverse: 'True'
20 }
21}))
22 .use(permalinks({
23 pattern: ':collections/:title'
24 }))
25 .use(templates({
26 engine: 'jade',
27 moment
28 }))
29 .use(beautify())
30 .destination('./build')
31 .build(function(err) {
32 if (err) {throw err; }
33 });
34
35app.use(serve(__dirname + '/build'));
36
37app.listen('3000');
38
39console.log('Metalwork is listening at http://localhost:3000/');