-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
99 lines (79 loc) · 2.26 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
98
99
'use strict';
const StaticSiteJson = require('broccoli-static-site-json');
const BroccoliMergeTrees = require('broccoli-merge-trees');
const funnel = require('broccoli-funnel');
const { readdirSync, existsSync } = require('fs');
const { join } = require('path');
const TocBuilder = require('./lib/toc-builder');
module.exports = {
name: require('./package').name,
config() {
return {
fastboot: {
hostWhitelist: [/localhost:\d+/],
},
showdown: {
tables: true,
},
};
},
getDataDirectory() {
if (
this.app.options.rfcProcess &&
this.app.options.rfcProcess.textLocation
) {
return this.app.options.rfcProcess.textLocation;
}
return join(this.project.configPath(), '../..');
},
urlsForPrember() {
const rfcs = readdirSync(join(this.getDataDirectory(), 'text'))
.map((file) => file.replace(/\.md$/, ''))
.map((file) => `/id/${file}`);
return ['/', ...rfcs];
},
treeForPublic() {
let dataDirectory = this.getDataDirectory();
const rfcsJSON = new StaticSiteJson(join(dataDirectory, 'text'), {
contentFolder: 'rfcs',
collate: true,
type: 'rfcs',
attributes: [
'start-date',
'release-date',
'release-versions',
'proposal-pr',
'tracking-link',
],
references: ['teams', 'stage'],
});
const teamsJSON = new StaticSiteJson(join(dataDirectory, 'teams'), {
contentFolder: 'teams',
collate: true,
type: 'teams',
attributes: ['name'],
});
const stagesJSON = new StaticSiteJson(join(dataDirectory, 'stages'), {
contentFolder: 'stages',
collate: true,
type: 'stages',
attributes: ['name', 'order'],
});
const readmeFile = funnel(dataDirectory, {
files: ['README.md'],
});
const pagesJSON = new StaticSiteJson(readmeFile, {
contentFolder: 'pages',
type: 'pages',
});
const tocTree = new TocBuilder(rfcsJSON);
const trees = [rfcsJSON, teamsJSON, stagesJSON, tocTree, pagesJSON];
if (existsSync(join(dataDirectory, 'images'))) {
const images = funnel(join(dataDirectory, 'images'), {
destDir: 'images',
});
trees.push(images);
}
return BroccoliMergeTrees(trees);
},
};