1 | var 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 |
|
11 | app = koa();
|
12 |
|
13 | metalsmith(__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 | console.log('Metalwork has been built');
|
34 | });
|
35 |
|
36 | app.use(serve(__dirname + '/build'));
|
37 |
|
38 | app.listen('3000');
|
39 |
|
40 | console.log('Metalwork is listening at http://localhost:3000/');
|