-
Notifications
You must be signed in to change notification settings - Fork 0
/
metalsmith.js
93 lines (87 loc) · 2.08 KB
/
metalsmith.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
88
89
90
91
92
93
var Metalsmith = require('metalsmith');
var Handlebars = require('handlebars');
var minimist = require('minimist');
var collections = require('metalsmith-collections');
var layouts = require('metalsmith-layouts');
var inplace = require('metalsmith-in-place');
var markdown = require('metalsmith-markdown');
var excerpts = require('metalsmith-excerpts');
var less = require('metalsmith-less');
var babel = require('metalsmith-babel');
var permalinks = require('metalsmith-permalinks');
var copy = require('metalsmith-static');
var ignore = require('metalsmith-ignore');
var watch = require('metalsmith-watch');
var serve = require('metalsmith-serve');
var debug = require('metalsmith-debug');
var gatoken = require('./uservars.json').gatoken;
var options = minimist(process.argv.slice(2));
Handlebars.registerHelper('link', function (path) {
return '/' + path.replace('/index.html', '');
});
var ms = Metalsmith(__dirname)
.source('./src')
.destination('./public')
.clean(true)
.metadata({
gatoken: gatoken
})
.use(less())
.use(babel({
presets: ['es2015']
}))
.use(markdown())
.use(excerpts())
.use(permalinks({
relative: false,
date: 'YYYYMM',
linksets: [{
match: { collection: 'minutes' },
pattern: 'minutes/:date'
},{
match: { collection: 'notices' },
pattern: 'notices/:title'
}]
}))
.use(collections({
minutes: {
sortBy: 'date',
reverse: true
},
notices: {
sortBy: 'date',
reverse: true
}
}))
.use(layouts({
engine: 'handlebars',
partials: 'partials'
}))
.use(inplace({
engine: 'handlebars'
}))
.use(copy([
{
src: 'lib',
dest: '.'
}, {
src: '/node_modules/stickybits/dist/stickybits.min.js',
dest: './js/stickybits.min.js'
}
]))
.use(ignore('less/*'));
if (options.serve) {
ms.use(watch({
paths: {
'${source}/**/*': true,
'layouts/**/*': '**/*',
'partials/**/*': '**/*',
'lib/**/*': '**/*'
}
}));
ms.use(serve());
}
ms.build(function (err) {
if (err) throw err;
else console.log('Complete!');
});