-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
77 lines (72 loc) · 1.92 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
var Metalsmith = require('metalsmith');
var markdown = require('metalsmith-markdown-remarkable');
var layouts = require('metalsmith-layouts');
var permalinks = require('metalsmith-permalinks');
var assets = require('metalsmith-assets-2');
var pagination = require('metalsmith-pagination');
var collections = require('metalsmith-collections');
var more = require('metalsmith-more');
var tags = require('metalsmith-tags');
var myserve = require('./myserve');
var Handlebars = require('handlebars');
Handlebars.registerHelper('dateFormat', require('handlebars-dateformat'));
var ms = Metalsmith(__dirname)
.metadata({
sitetitle: "haxx populi",
sitedescription: "tips and tricks from a working coder",
siteurl: "http://haxx.sinequanon.net/"
})
.source('./src')
.destination('./build')
.clean(false) // must be false to use gh-pages clone as build/
.use(collections({
posts: {
sortBy: 'date',
reverse: true,
pattern: 'posts/**/*.md',
}
}))
.use(markdown('full',{
html: true,
linkify: true,
}))
.use(more({
alwaysAddKey: true,
regexp: /\s*<(!--\s*more\s*--|h2\s*id="comments"\s*)>/,
}))
.use(permalinks({
pattern: ':date/:slug',
date: 'YYYY/MM',
linksets: [{
match: { layout: 'page' },
pattern: ':slug',
}]
}))
.use(pagination({
'collections.posts': {
first:'index.html',
layout:'pagination',
path: 'page/:num/index.html',
}
}))
.use(tags({
path: 'tag/:tag/index.html',
pathPage: 'tag/:tag/:num/index.html',
sortBy: 'date',
reverse: true,
perPage: 10,
layout: 'tag',
}))
.use(layouts({
engine: 'handlebars',
default: 'post',
partials: 'layouts',
}))
.use(assets({
source: './static',
destination: '.',
}))
if ('--run' === process.argv[2]) { ms = ms.use(myserve()); }
ms.build(function(err, files) {
if (err) { throw err; }
});