forked from spotinst/help
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneratePaths.js
More file actions
29 lines (21 loc) · 834 Bytes
/
Copy pathgeneratePaths.js
File metadata and controls
29 lines (21 loc) · 834 Bytes
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
const fs = require("fs");
const path = require("path");
const DOCS_DIR = path.join(__dirname, "src/docs");
const OUTPUT_FILE = path.join(__dirname, "src/docs/paths.json");
function getAllMarkdownFiles(dir, baseDir = "/") {
let results = [];
const files = fs.readdirSync(dir);
files.forEach((file) => {
const fullPath = path.join(dir, file);
const relativePath = path.join(baseDir, file);
if (fs.statSync(fullPath).isDirectory()) {
results = results.concat(getAllMarkdownFiles(fullPath, relativePath));
} else if (file.endsWith(".md")) {
results.push(relativePath.replace(/\\/g, "/"));
}
});
return results;
}
const paths = getAllMarkdownFiles(DOCS_DIR);
fs.writeFileSync(OUTPUT_FILE, JSON.stringify(paths, null, 2));
console.log(`Generated paths.json with ${paths.length} entries.`);