-
Notifications
You must be signed in to change notification settings - Fork 40
/
faq.js
35 lines (28 loc) · 1011 Bytes
/
faq.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
const path = require("path");
const fs = require("fs");
// concatenate faq's into one file
const faqDir = path.join(__dirname, 'faq');
const files = fs.readdirSync(faqDir);
files.sort();
const outfile = path.join(__dirname, 'docs', 'user-manual', 'faq.md');
const stream = fs.createWriteStream(outfile);
stream.once('open', () => {
// write header
stream.write('---\n');
stream.write('title: Common Questions\n');
stream.write('sidebar_position: 25\n');
stream.write('---\n\n');
const processFile = (content) => {
let processed = content.replace(/font-icon/g, 'pc-icon');
processed = processed.replace(/^---[\s\S]*?[\s\S]---/, '');
processed = processed.replace(/^\n*/, '');
return processed + '\n';
};
// write file content
files.forEach((file) => {
const content = fs.readFileSync(path.join(faqDir, file), 'utf8');
const processed = processFile(content);
stream.write(processed);
});
stream.end();
});