forked from ipfs-inactive/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
87 lines (75 loc) · 1.94 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env node
var Metalsmith = require('metalsmith')
var debug = require('metalsmith-debug')
var templates = require('metalsmith-templates')
var collections = require('metalsmith-collections')
var serve = require('metalsmith-serve')
var watch = require('metalsmith-watch')
var markdown = require('metalsmith-markdown')
var permalinks = require('metalsmith-permalinks')
var feed = require('metalsmith-feed')
var msstatic = require('metalsmith-static')
var drafts = require('metalsmith-drafts')
var headingsidentifier = require('metalsmith-headings-identifier')
var msIf = require('metalsmith-if')
var nunjucks = require('nunjucks')
var njmd = require('nunjucks-markdown')
var njdate = require('nunjucks-date')
var marked = require('marked')
var meow = require('meow')
var cli = meow(`
Usage
$ node build.js
Options
-w, --watch Watch the files
Examples
$ node build.js --watch
`)
marked.setOptions({
gfm: true,
tables: true,
smartLists: true
})
var njenv = nunjucks.configure({watch: cli.flags.watch})
njmd.register(njenv, marked)
njdate.setDefaultFormat('YYYY-MM-DD, h:mm:ss a')
njdate.install(njenv)
njenv.addFilter('dump', JSON.stringify)
Metalsmith(__dirname)
.use(debug())
.use(drafts())
.metadata({
site: {
title: 'IPFS Blog',
url: 'http://ipfs.io/blog/',
author: 'The IPFS Team'
}
})
.use(collections({
posts: {}
}))
.use(markdown())
.use(templates({ 'directory': '.', 'engine': 'nunjucks', 'inPlace': true }))
.use(templates({ 'directory': '.', 'engine': 'nunjucks' }))
.use(headingsidentifier())
.use(permalinks())
.use(feed({'collection': 'posts'}))
.use(msstatic({'src': 'tmpl/static', 'dest': 'static'}))
.use(msIf(
cli.flags.watch,
serve({
'port': 8081,
'verbose': true
})
))
.use(msIf(
cli.flags.watch,
watch()
))
.destination('./build')
.build(function (err) {
if (err) {
console.log(err)
throw err
}
})