forked from celestiaorg/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
importMarkdown.mjs
43 lines (40 loc) · 1.35 KB
/
importMarkdown.mjs
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
import fs from 'fs';
import fetch from 'node-fetch';
const filesToImport = [
{
url: 'https://raw.githubusercontent.com/celestiaorg/orchestrator-relayer/main/docs/deploy.md',
fileName: 'qgb-deploy.md',
},
{
url: 'https://raw.githubusercontent.com/celestiaorg/orchestrator-relayer/main/docs/keys.md',
fileName: 'qgb-keys.md',
},
{
url: 'https://raw.githubusercontent.com/celestiaorg/orchestrator-relayer/main/docs/orchestrator.md',
fileName: 'qgb-orchestrator.md',
},
{
url: 'https://raw.githubusercontent.com/celestiaorg/orchestrator-relayer/main/docs/relayer.md',
fileName: 'qgb-relayer.md',
},
// TODO: add introduction to QGB section
// {
// url: 'https://raw.githubusercontent.com/celestiaorg/orchestrator-relayer/main/README.md',
// fileName: 'qgb-intro.md',
// },
];
async function importMarkdown(file) {
try {
const response = await fetch(file.url);
if (response.ok) {
const markdown = await response.text();
fs.writeFileSync(`./docs/nodes/${file.fileName}`, markdown);
console.log(`Markdown file '${file.fileName}' successfully imported!`);
} else {
console.error(`Error fetching the markdown file: ${response.statusText}`);
}
} catch (error) {
console.error(`Error importing the markdown file: ${error.message}`);
}
}
filesToImport.forEach(importMarkdown);