-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
73 lines (68 loc) · 1.67 KB
/
index.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
var Metalsmith = require('metalsmith');
var markdown = require('metalsmith-markdown');
var layouts = require('metalsmith-layouts');
var sass = require('metalsmith-sass');
var metadata = require('metalsmith-metadata');
var relative = require('metalsmith-relative');
var collections = require('metalsmith-collections');
var filepath = require('metalsmith-filepath');
var inplace = require('metalsmith-in-place');
var ignore = require('metalsmith-ignore');
var define = require('metalsmith-define');
var url = require('url');
var serveMode = process.argv.indexOf('--serve') != -1;
var site = Metalsmith(__dirname)
.source('./src')
.destination('./build')
.metadata({
serve: serveMode,
})
.use(ignore(['**/.DS_Store']))
.use(collections({
pages: {
pattern: '*.{md,html,pug}',
sort: 'order',
}
}))
.use(metadata({
course: 'course.yaml',
schedule: 'schedule.yaml'
}))
.use(relative())
.use(define({
resolve: url.resolve, // Path join helper.
}))
.use(inplace({
engine: "handlebars",
pattern: "*.{html,md}"
}))
.use(inplace({
engine: "pug",
pattern: "*.pug",
rename: true,
}))
.use(markdown({
smartypants: true,
}))
.use(sass())
.use(filepath({
absolute: true
}))
.use(layouts('handlebars'));
if (serveMode) {
var serve = require('metalsmith-serve');
var watch = require('metalsmith-watch');
site = site
.use(serve())
.use(watch({
paths: {
"${source}/**/*": true,
"layouts/**/*": "**/*.md",
"${source}/**/*.yaml": "**/*",
},
livereload: true
}));
}
site.build(function(err) {
if (err) throw err;
});