-
Notifications
You must be signed in to change notification settings - Fork 0
/
verbfile.js
56 lines (46 loc) · 1.14 KB
/
verbfile.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
'use strict';
const path = require('path');
const yaml = require('js-yaml');
let loaded = false;
module.exports = function(app) {
app.use(require('verb-generate-readme'));
app.data.options.namespace = function(fp) {
return path.basename(fp, path.extname(fp));
};
function loadOnce() {
loaded = true;
app.dataLoader(/\.yml$/, function(data) {
return yaml.safeLoad(data);
});
app.data('terminology.yml');
}
if (!loaded) {
loadOnce();
}
app.helper('words', function(words = []) {
let str = '**Related words**: ';
const len = words.length;
if (len === 0) return '';
for (let i = 0; i < len; i++) {
const word = words[i];
if (i !== 0 && i < len) {
str += ', ';
}
str += '[' + word + '](#' + word + ')';
}
return str;
});
app.helper('projects', function(repos = []) {
let str = '**Related projects**: ';
const len = repos.length;
if (len === 0) return '';
for (let i = 0; i < len; i++) {
const repo = repos[i];
if (i !== 0 && i < len) {
str += ', ';
}
str += '[' + repo + '][]';
}
return str;
});
};