-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
88 lines (84 loc) · 2.08 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require('harmonize')();
var Metalsmith = require('metalsmith'),
sass = require('metalsmith-sass'),
serve = require('metalsmith-serve'),
assets = require('metalsmith-assets'),
layouts = require('metalsmith-layouts'),
inPlace = require('metalsmith-in-place'),
markdown = require('metalsmith-markdown'),
permalinks = require('metalsmith-permalinks'),
collections = require('metalsmith-collections'),
excerpts = require('metalsmith-excerpts'),
pagination = require('metalsmith-pagination'),
hbsHelpers = require('metalsmith-register-helpers'),
myPlugins = require('./lib/metalsmith-plugins');
var m = Metalsmith(__dirname)
.use(hbsHelpers({
directory: 'hbs_helpers'
}))
.use(collections({
posts: {
pattern: 'content/posts/*.md'
},
pages: {
pattern: 'content/pages/*.md'
}
}))
.use(markdown({
'smartypants': true,
'gfm': true,
'tables': true
}))
.use(excerpts())
.use(permalinks({
pattern: ':title',
linksets: [{
match: {collection: 'posts'},
pattern: 'blog/:date/:title'
}]
}))
.use(pagination({
'collections.posts': {
perPage: 5,
layout: 'blog.hbs',
first: 'blog/index.html',
path: 'blog/:num/index.html',
filter: function (page) {
return !page.private;
},
pageMetadata: {
title: 'Blog'
}
}
}))
.use(myPlugins.addSocialsToMetadata)
.use(myPlugins.setUrlPrefix)
.use(layouts({
engine: 'handlebars',
partials: 'partials'
}))
.use(inPlace({
engine: 'handlebars'
}))
.use(assets({
source: 'src/assets', // relative to the working directory
destination: './assets' // relative to the build directory
}))
.use(assets({
source: 'node_modules/font-awesome/fonts',
destination: './assets/fonts'
}))
// Process css
.use(sass({
sourceMap: true,
sourceMapContents: true
}))
.destination('./build');
if (process.argv[2] === '--serve') {
m.use(serve({}));
}
m.build(function (err) {
if (err) {
console.error(err);
}
});