-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
97 lines (93 loc) · 2.79 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
89
90
91
92
93
94
95
96
97
var Metalsmith = require('metalsmith'),
branch = require('metalsmith-branch'),
markdown = require('metalsmith-markdown'),
templates = require('metalsmith-templates'),
collections = require('metalsmith-collections'),
permalinks = require('metalsmith-permalinks'),
paginate = require('metalsmith-pagination'),
drafts = require('metalsmith-drafts'),
gist = require('metalsmith-gist'),
tags = require('metalsmith-tags'),
snippet = require('metalsmith-snippet'),
Handlebars = require('handlebars'),
fs = require('fs'),
moment = require('moment')
sass = require('metalsmith-sass');
autoprefixer = require('metalsmith-autoprefixer'),
metallic = require('metalsmith-metallic'),
cleanCSS = require('metalsmith-clean-css'),
uglify = require('metalsmith-uglify'),
htmlescape = require('metalsmith-htmlescape'),
headingsId = require('metalsmith-headings-identifier'),
watch = require('metalsmith-watch'),
serve = require('metalsmith-serve'),
metadata = require('metalsmith-metadata');
Handlebars.registerPartial('header', fs.readFileSync(__dirname + '/templates/partials/header.hbt').toString());
Handlebars.registerPartial('footer', fs.readFileSync(__dirname + '/templates/partials/footer.hbt').toString());
Handlebars.registerHelper('prettifyDate', function(timestamp) {
return moment(new Date(timestamp)).format('dddd, MMMM Do YYYY');
});
Metalsmith(__dirname)
.use(sass({
outputStyle: 'expanded',
outputDir: 'css/'
}))
.use(metallic())
.use(autoprefixer())
.use(drafts())
// .use(tags({
// path: 'topics',
// template: 'tag.hbt',
// sortBy: 'date',
// reverse: true
// }))
.use(gist())
.use(collections({
blog: {
pattern: 'posts/*.md',
sortBy: 'date',
reverse: true
}
}))
.use(metadata({
globals: 'globals.json',
}))
.use(paginate({
'collections.blog': {
perPage: 100,
template: 'paginate.hbt',
first: 'blog/index.html',
path: 'blog/page/:num/index.html',
pageMetadata: {
title: 'Blog Archive'
}
}
}))
.use(markdown())
.use(branch('posts/*')
.use(permalinks({
pattern: ':collection/:title',
relative: false
}))
)
// .use(cleanCSS())
// .use(uglify())
.use(snippet({
maxLength: 250,
suffix: '...'
}))
.use(templates('handlebars'))
.use(htmlescape())
.use(headingsId({
linkTemplate: "<a class='heading-anchor' href='#%s' aria-hidden='true'><span></span></a>",
allow: "headingAnchor"
}))
.use(watch({
pattern: '**/*',
livereload: true
}))
.use(serve())
.destination('./build')
.build(function(err, files) {
if (err) { throw err; }
});