-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-prd.js
138 lines (131 loc) · 3.98 KB
/
build-prd.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
const metalsmith = require('metalsmith');
const metallic = require('metalsmith-metallic');
const drafts = require('metalsmith-drafts');
const discoverPartials = require('metalsmith-discover-partials');
const commento = require('metalsmith-commento');
const markdown = require('metalsmith-markdown');
const layouts = require('metalsmith-layouts');
const handlebars = require('handlebars');
const groupBy = require('handlebars-group-by');
const collections = require('metalsmith-collections');
const yearly_pagination = require('metalsmith-yearly-pagination');
const permalinks = require('metalsmith-permalinks');
const serve = require('metalsmith-serve');
const watch = require('metalsmith-watch');
const assets = require('metalsmith-assets');
const pagination = require('metalsmith-pagination');
const tags = require('metalsmith-tags');
const excerpts = require('metalsmith-excerpts');
handlebars.registerHelper('moment', require('helper-moment'));
handlebars.registerHelper(groupBy(handlebars));
handlebars.registerHelper('limit', function(collection, limit, start) {
var out = [],
i, c;
start = start || 0;
for (i = c = 0; i < collection.length; i++) {
if (i >= start && c < limit+1) {
out.push(collection[i]);
c++;
}
}
return out;
});
var logPlugin = function(files, metalsmith, done) {
// console.log(files);
console.log(metalsmith);
done();
};
metalsmith(__dirname)
.metadata({
site: {
name: 'Adom',
description: "Blog about Microsoft technologies (.NET, .NET Core, ASP.NET Core, Azure, etc.)",
prefixLink: 'blog/'
}
})
.source('./src')
.destination('./docs')
.use(drafts())
.use(collections({
articles:{
pattern: 'articles/**/*.md',
sortBy: 'date',
reverse: true
}
}))
.use(pagination({
'collections.articles': {
perPage: 5,
layout:'index.hbs',
first: 'index.html',
path: 'page/:num/index.html',
pageMetadata: {
title: 'Archive'
}
}
}))
.use(yearly_pagination({ path: 'archives/year' }))
.use(discoverPartials())
.use(metallic())
.use(markdown())
.use(commento({
autoInit: false,
idRoot: 'comments-block',
counterSelector: '.comments-counter'
}))
.use(excerpts({ multipleFormat: true }))
.use(permalinks({
relative: false,
pattern: ':title',
}))
.use(tags({
// yaml key for tag list in you pages
handle: 'tags',
// path for result pages
path:'topics/:tag.html',
// layout to use for tag listing
layout:'tag.hbs',
// Can also use `template` property for use with the (deprecated)
// metalsmith-templates plugin. The `template` property is deprecated here
// as well but still available for use.
// template:'/partials/tag.hbt',
// ------
// Normalize special characters like ØçßÜ to their ASCII equivalents ocssü
// makes use of the value assigned to the 'slug' property below
normalize: true,
// provide posts sorted by 'date' (optional)
sortBy: 'date',
// sort direction (optional)
reverse: true,
// skip updating metalsmith's metadata object.
// useful for improving performance on large blogs
// (optional)
skipMetadata: false,
// Use a non-default key in the metadata. Useful if you you want to
// have two sets of tags in different sets with metalsmith-branch.
metadataKey: "category",
// Any options you want to pass to the [slug](https://github.com/dodo/node-slug) package.
// Can also supply a custom slug function.
// slug: function(tag) { return tag.toLowerCase() }
slug: {mode: 'rfc3986'}
}))
.use(layouts({
engine: 'handlebars',
directory: './layouts',
pattern: ["*/*/*html","*/*html","*html"],
default: 'article.hbs',
suppressNoFilesError: false,
}))
.use(assets({
source: './layouts/assets',
destination: './assets'
}))
.use(logPlugin)
.build(function (err) {
if (err) {
console.log(err);
}
else {
console.log('Blog built!');
}
});