1 | const path = require('path'),
|
2 | koa = require('koa'),
|
3 | serve = require('koa-static'),
|
4 | metalsmith = require('metalsmith'),
|
5 | markdown = require('metalsmith-markdown'),
|
6 | layouts = require('metalsmith-layouts'),
|
7 | collections = require('metalsmith-collections'),
|
8 | permalinks = require('metalsmith-permalinks'),
|
9 | feed = require('metalsmith-feed'),
|
10 | moment = require('moment')
|
11 |
|
12 | const site = {
|
13 | author: 'Ev Bogue',
|
14 | photo: 'evbogue-badass.jpg',
|
15 | title: 'Metalwork',
|
16 | url: 'http://evbogue.com/metalwork/',
|
17 | port: '3000'
|
18 | };
|
19 |
|
20 | const blog = {
|
21 | pattern: './*.md',
|
22 | reverse: true,
|
23 | sortBy: 'date'
|
24 | };
|
25 |
|
26 | metalsmith(__dirname)
|
27 | .metadata({site})
|
28 | .use(markdown())
|
29 | .use(collections({blog}))
|
30 | .use(permalinks({pattern: ':collections:title'}))
|
31 | .use(feed({collection: 'blog'}))
|
32 | .use(layouts({engine: 'jade', moment}))
|
33 | .destination('./build')
|
34 | .build(function(err) {
|
35 | if (err) {throw err; }
|
36 | console.log('Metalwork is built');
|
37 | });
|
38 |
|
39 |
|
40 | app = koa();
|
41 |
|
42 | app.use(serve(path.join(__dirname, 'bower')));
|
43 | app.use(serve(path.join(__dirname, 'build')));
|
44 | app.listen(site.port);
|
45 |
|
46 | console.log(`Metalwork is listening at http://localhost:${site.port}/`);
|
47 |
|