-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeDocsManifest.js
39 lines (32 loc) · 983 Bytes
/
makeDocsManifest.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
const { resolve, join } = require('path');
const { promises } = require('fs');
const makeDocumentIndex = require('./documentIndexer');
const contents = require('./contents');
(async () => {
const manifest = { groups: [], pages: [] };
for (const { group, label, pages } of contents) {
manifest.groups.push(label);
for (const page of pages) {
console.log('Loading', page);
const fileName = join(group, `${page}.md`);
const fileContents = await promises.readFile(
join(__dirname, './docs', fileName),
);
const { sections, parent } = makeDocumentIndex(fileContents);
const route = parent
? `/documentation/${parent}/${page}/`
: `/documentation/${page}/`;
manifest.pages.push({
group,
label,
fileName,
route,
sections,
});
}
}
await promises.writeFile(
resolve(__dirname, 'docs-manifest.json'),
JSON.stringify(manifest, null, 2),
);
})();