-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsidebars.js
More file actions
74 lines (66 loc) · 1.69 KB
/
Copy pathsidebars.js
File metadata and controls
74 lines (66 loc) · 1.69 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// @ts-check
import fs from 'node:fs';
import path from 'node:path';
const docsDir = path.resolve('docs');
const servicesDir = path.join(docsDir, 'services');
function frontMatterTitle(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const match = content.match(/^title:\s*(.+)$/m);
if (!match) {
return path.basename(filePath, '.md');
}
try {
return JSON.parse(match[1]);
} catch {
return match[1].replace(/^["']|["']$/g, '');
}
}
const serviceItems = fs
.readdirSync(servicesDir)
.filter((fileName) => fileName.endsWith('.md'))
.sort()
.map((fileName) => {
const serviceKey = path.basename(fileName, '.md');
const articleDir = `services/${serviceKey}`;
const articlePath = path.join(docsDir, articleDir);
return {
type: 'category',
label: frontMatterTitle(path.join(servicesDir, fileName)),
className: `service-sidebar-item service-sidebar-${serviceKey}`,
customProps: {
serviceKey,
},
link: {
type: 'doc',
id: `services/${serviceKey}`,
},
items: fs.existsSync(articlePath)
? [{type: 'autogenerated', dirName: articleDir}]
: [],
};
});
const sidebars = {
briefingSidebar: [
{
type: 'doc',
id: 'index',
label: 'Today in Tech',
className: 'todayintech-sidebar-home',
},
...serviceItems,
],
operationsSidebar: [
{
type: 'doc',
id: 'operations/index',
label: '트레이스',
className: 'operations-sidebar-item',
},
'operations/services',
'operations/collection',
'operations/preprocessing',
'operations/enrichment',
'operations/writer',
],
};
export default sidebars;