Skip to content

Commit 1f39fae

Browse files
committed
feat: restructure sidebar categories and update client cache directory
1 parent f9d63a0 commit 1f39fae

File tree

4 files changed

+520
-23
lines changed

4 files changed

+520
-23
lines changed

src/sidebars/generate-index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
function walkDocs(dir, base = '') {
5+
const entries = fs.readdirSync(dir, { withFileTypes: true });
6+
let items = [];
7+
for (const entry of entries) {
8+
if (entry.isDirectory()) {
9+
// Recursively walk subdirectories
10+
const subItems = walkDocs(path.join(dir, entry.name), path.join(base, entry.name));
11+
if (subItems.length > 0) {
12+
items.push({
13+
type: 'category',
14+
label: entry.name.charAt(0).toUpperCase() + entry.name.slice(1),
15+
items: subItems
16+
});
17+
}
18+
} else if (entry.isFile() && (entry.name.endsWith('.md') || entry.name.endsWith('.mdx'))) {
19+
// Remove extension for id
20+
const id = path.join(base, entry.name).replace(/\\/g, '/').replace(/\.(md|mdx)$/, '');
21+
items.push({
22+
type: 'doc',
23+
id
24+
});
25+
}
26+
}
27+
return items;
28+
}
29+
30+
const docsDir = path.join(__dirname, '../../docs');
31+
const sidebar = { items: walkDocs(docsDir) };
32+
33+
fs.writeFileSync(
34+
path.join(__dirname, 'index.json'),
35+
JSON.stringify(sidebar, null, 4)
36+
);
37+
console.log('Sidebar index.json generated!');

0 commit comments

Comments
 (0)