This repository has been archived by the owner on Jun 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (64 loc) · 1.64 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
const Metalsmith = require('metalsmith');
const layouts = require('metalsmith-layouts');
const pagination = require('metalsmith-pagination')
const metadata = require('metalsmith-metadata')
const markdown = require('metalsmith-markdown')
const collections = require('metalsmith-collections')
const watch = require('metalsmith-watch')
const collectionMetadata = require('metalsmith-collection-metadata')
const msIf = require('metalsmith-if');
const htmlMinifier = require("metalsmith-html-minifier");
const marked = require('marked');
const tag = require('html-tag');
const isDevelopment = process.env.NODE_ENV == 'development';
Metalsmith(__dirname)
.source('./src')
.destination('./build')
.metadata({
environment: isDevelopment ? 'development' : 'production'
})
.use(msIf(
isDevelopment,
watch({
paths: {
"src/**/*": "**/*",
"layouts/**/*": "**/*",
},
livereload: isDevelopment
})
))
.use(metadata({
settings: 'data/settings.yml'
}))
.use(markdown())
.use(collections({
works: {
pattern: 'works/*.html',
sortBy: 'position',
}
}))
.use(collectionMetadata({
'collections.works': {
layout: 'work.ejs',
},
}))
.use(pagination({
'collections.works': {
perPage: 5,
layout: 'works.ejs',
first: 'index.html',
path: 'works/page/:num/index.html',
}
}))
.use(layouts({
engine: 'ejs',
rename: true,
markdown: marked,
tagGenerator({ tagName, attributes, content }) {
return tag(tagName, attributes, content);
}
}))
.use(htmlMinifier())
.build(function(err, files) {
if (err) { throw err; }
});