This repository was archived by the owner on Feb 17, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
126 lines (109 loc) · 3.01 KB
/
build.js
File metadata and controls
126 lines (109 loc) · 3.01 KB
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
'use strict';
var path = require('path');
var Nunjucks = require('nunjucks');
var metalsmith = require('metalsmith');
var markDown = require('metalsmith-markdown');
var sass = require('metalsmith-ruby-sass');
var templates = require('metalsmith-templates');
var navigation = require('metalsmith-navigation');
var excerpts = require('metalsmith-excerpts');
var metallic = require('metalsmith-metallic');
var assets = require('metalsmith-assets');
var watch = require('metalsmith-watch');
var lunr = require('metalsmith-lunr');
var navTask = navigation(navConfigs);
var navConfigs = {
primary:{
sortBy: 'nav_sort',
filterProperty: 'nav_groups',
},
list_page:{
sortBy: 'nav_sort',
filterProperty: 'nav_groups',
},
footer:{
sortBy: 'nav_sort',
filterProperty: 'nav_groups',
}
};
var relativePathHelper = function(current, target) {
// normalize and remove starting slash from path
if(!current || !target){
return '';
}
current = path.normalize(current).slice(0);
target = path.normalize(target).slice(0);
current = path.dirname(current);
var relative = path.relative(current, target);
relative = relative.replace(/\\/g,"/");
return relative;
};
var indexPathHelper = function(current, target) {
// normalize and remove starting slash from path
if(!current || !target){
return '';
}
current = path.normalize(current).slice(0);
target = path.normalize(target).slice(0);
current = path.dirname(current);
var index = path.relative(current, target);
index = index.replace(/\\/g,"/");
return path.dirname(index)+'/';
};
var navTask = navigation(navConfigs);
var markDownTask = markDown();
var metallicTask = metallic();
var excerptsTask = excerpts();
var watchTask = watch({
pattern : ['**/*', '../templates/**/*'],
livereload: true
});
var sassTask = sass({
outputDir: 'css/',
outputStyle: 'compressed'
})
var templatesTask = templates({
engine: 'nunjucks',
settings: {
views: 'templates',
filters: {
'relativePath': relativePathHelper,
'indexPath': indexPathHelper
}
}
});
var assetsTask = assets({
source: './assets', // relative to the working directory
destination: './assets' // relative to the build directory
})
var meta = {
siteTitle: 'fednet',
description: 'Front end developer knowledge.',
};
var lunrTask = lunr({
// ref: 'title',
fields: {
title: 1,
contents: 10
},
store: ['title', 'excerpt', 'nav_path'],
preprocess: function(content) {
//Strip html tags
return content.replace(/(<([^>]+)>)/ig,"");
}
})
var metalsmith = metalsmith(__dirname)
.clean(true)
.metadata(meta)
.use(markDownTask)
.use(excerptsTask)
.use(metallicTask)
.use(sassTask)
.use(navTask)
.use(templatesTask)
.use(assetsTask)
.use(lunrTask)
//.use(watchTask)
.build(function(err) {
if (err) throw err;
});