Skip to content

Commit aa9a3df

Browse files
committed
refactor: using as tree style
1 parent 4147a6b commit aa9a3df

File tree

1 file changed

+107
-86
lines changed

1 file changed

+107
-86
lines changed

docs/.vitepress/config.ts

Lines changed: 107 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,230 +1,251 @@
1-
// .vitepress/config.js
1+
// .vitepress/config.ts
22

33
const sidebar = (lang = "", override = {}) => {
4-
const items = [
5-
{ page: "getting-started/introduction", text: "Introduction" },
6-
{ page: "getting-started/installation", text: "Installation" },
7-
{ page: "reference/commands", text: "Commands" },
8-
{ page: "reference/overview-scripts", text: "Overview Scripts" },
9-
{ page: "project/roadmap", text: "Roadmap" },
10-
{ page: "project/contributing", text: "Contributing" },
11-
{ page: "project/codeofconduct", text: "Code of Conduct" },
12-
{ page: "project/inspiration", text: "Inspiration" },
13-
{ page: "project/contributors", text: "Contributions" },
14-
];
4+
const prefix = lang ? `/${lang}` : "";
155

16-
return items.map(item => {
17-
let path = "/";
18-
19-
if (lang) {
20-
path += `${lang}/`;
21-
}
22-
23-
if (item.page) {
24-
path += `${item.page}`;
25-
}
26-
27-
return {
28-
link: path,
29-
text: override[item.page] || item.text
30-
};
31-
});
6+
return [
7+
{
8+
text: override["getting-started"] || "Getting Started",
9+
collapsed: false,
10+
items: [
11+
{
12+
text: override["getting-started/introduction"] || "Introduction",
13+
link: `${prefix}/getting-started/introduction`,
14+
},
15+
{
16+
text: override["getting-started/installation"] || "Installation",
17+
link: `${prefix}/getting-started/installation`,
18+
},
19+
],
20+
},
21+
{
22+
text: override["reference"] || "Reference",
23+
collapsed: false,
24+
items: [
25+
{
26+
text: override["reference/commands"] || "Commands",
27+
link: `${prefix}/reference/commands`,
28+
},
29+
{
30+
text: override["reference/overview-scripts"] || "Overview Scripts",
31+
link: `${prefix}/reference/overview-scripts`,
32+
},
33+
],
34+
},
35+
{
36+
text: override["project"] || "Project",
37+
collapsed: false,
38+
items: [
39+
{
40+
text: override["project/roadmap"] || "Roadmap",
41+
link: `${prefix}/project/roadmap`,
42+
},
43+
{
44+
text: override["project/contributing"] || "Contributing",
45+
link: `${prefix}/project/contributing`,
46+
},
47+
{
48+
text: override["project/codeofconduct"] || "Code of Conduct",
49+
link: `${prefix}/project/codeofconduct`,
50+
},
51+
{
52+
text: override["project/inspiration"] || "Inspiration",
53+
link: `${prefix}/project/inspiration`,
54+
},
55+
{
56+
text: override["project/contributors"] || "Contributions",
57+
link: `${prefix}/project/contributors`,
58+
},
59+
],
60+
},
61+
];
3262
};
3363

3464
const nav = (lang = "", override = {}) => {
3565
let guidePath = "/getting-started/introduction";
36-
37-
if (lang) {
38-
guidePath = `/${lang}/getting-started/introduction`;
39-
}
66+
if (lang) guidePath = `/${lang}/getting-started/introduction`;
4067

4168
return [
4269
{ text: override.home || "Home", link: lang ? `/${lang}/` : "/" },
4370
{ text: override.guide || "Guide", link: guidePath },
44-
{
71+
{
4572
text: "4.4.7",
4673
items: [
4774
{
48-
text: override.changelog || 'Changelog',
49-
link: 'https://github.com/harilvfs/carch/blob/main/CHANGELOG.md'
75+
text: override.changelog || "Changelog",
76+
link: "https://github.com/harilvfs/carch/blob/main/CHANGELOG.md",
5077
},
5178
],
5279
},
5380
];
5481
};
5582

5683
export default {
57-
title: 'Carch',
58-
description: 'Documentation website of Carch',
84+
title: "Carch",
85+
description: "Documentation website of Carch",
5986
lastUpdated: true,
6087
cleanUrls: true,
61-
base: '/',
62-
63-
// Rewrites for different language folders
64-
// rewrites: {
65-
// "README.md": "index.md",
66-
// "np/README.md": "np/index.md",
67-
// "hi/README.md": "hi/index.md",
68-
// ":lang/:path*": ":lang/:path*"
69-
// },
70-
71-
head: [
72-
["link", { rel: "icon", href: "/carch.png" }],
73-
],
88+
base: "/",
89+
90+
head: [["link", { rel: "icon", href: "/carch.png" }]],
7491

7592
locales: {
7693
root: {
7794
label: "English",
7895
lang: "en-US",
7996
title: "Carch",
8097
description: "Documentation website of CArch",
81-
98+
8299
themeConfig: {
83100
siteTitle: "Carch",
84101
logo: "/carch.png",
85102
outline: "deep",
86103
docsDir: "/docs",
87-
104+
88105
editLink: {
89106
pattern: "https://github.com/carch-org/docs/tree/main/docs/:path",
90107
text: "Edit this page on GitHub",
91108
},
92-
109+
93110
nav: nav("", {}),
94111
sidebar: sidebar("", {}),
95-
112+
96113
socialLinks: [
97114
{ icon: "telegram", link: "https://t.me/carchx" },
98115
{ icon: "discord", link: "https://discord.com/invite/8NJWstnUHd" },
99116
{ icon: "gmail", link: "mailto:[email protected]" },
100117
],
101-
118+
102119
footer: {
103120
message: "Released under the MIT License.",
104121
copyright: "Copyright © 2025 Hari Chalise",
105122
},
106-
107-
returnToTopLabel: 'Go to Top',
108-
sidebarMenuLabel: 'Menu',
109-
}
123+
124+
returnToTopLabel: "Go to Top",
125+
sidebarMenuLabel: "Menu",
126+
},
110127
},
111128

112129
np: {
113130
label: "नेपाली",
114-
lang: "ne-NP",
131+
lang: "ne-NP",
115132
title: "सी-आर्च",
116133
description: "सी-आर्चको कागजात वेबसाइट",
117-
134+
118135
themeConfig: {
119136
siteTitle: "सी-आर्च",
120137
logo: "/carch.png",
121138
outline: "deep",
122139
docsDir: "/docs",
123-
140+
124141
langMenuLabel: "भाषाहरू",
125142
returnToTopLabel: "माथि जानुहोस्",
126143
sidebarMenuLabel: "मेनु",
127-
144+
128145
editLink: {
129146
pattern: "https://github.com/carch-org/docs/tree/main/docs/:path",
130147
text: "GitHub मा यो पृष्ठ सम्पादन गर्नुहोस्",
131148
},
132-
149+
133150
nav: nav("np", {
134151
home: "घर",
135152
guide: "गाइड",
136-
changelog: "परिवर्तन लग"
153+
changelog: "परिवर्तन लग",
137154
}),
138-
155+
139156
sidebar: sidebar("np", {
157+
"getting-started": "सुरुवात गर्नुहोस्",
140158
"getting-started/introduction": "परिचय",
141159
"getting-started/installation": "स्थापना",
160+
"reference": "सन्दर्भ",
142161
"reference/commands": "आदेशहरू",
143162
"reference/overview-scripts": "स्क्रिप्ट सिंहावलोकन",
163+
"project": "परियोजना",
144164
"project/roadmap": "रोडम्याप",
145165
"project/contributing": "योगदान",
146166
"project/codeofconduct": "आचार संहिता",
147167
"project/inspiration": "प्रेरणा",
148-
"project/contributors": "योगदानकर्ताहरू"
168+
"project/contributors": "योगदानकर्ताहरू",
149169
}),
150-
170+
151171
socialLinks: [
152172
{ icon: "telegram", link: "https://t.me/carchx" },
153173
{ icon: "discord", link: "https://discord.com/invite/8NJWstnUHd" },
154174
{ icon: "gmail", link: "mailto:[email protected]" },
155175
],
156-
176+
157177
footer: {
158178
message: "MIT लाइसेन्स अन्तर्गत जारी।",
159179
copyright: "प्रतिलिपि अधिकार © २०२५ हरि चालिसे",
160180
},
161-
162-
}
181+
},
163182
},
164183

165184
hi: {
166185
label: "हिन्दी",
167186
lang: "hi-IN",
168187
title: "सी-आर्च",
169188
description: "सी-आर्च की दस्तावेज़ वेबसाइट",
170-
189+
171190
themeConfig: {
172191
siteTitle: "सी-आर्च",
173192
logo: "/carch.png",
174193
outline: "deep",
175194
docsDir: "/docs",
176-
195+
177196
langMenuLabel: "भाषाएं",
178197
returnToTopLabel: "ऊपर जाएं",
179198
sidebarMenuLabel: "मेनू",
180-
199+
181200
editLink: {
182201
pattern: "https://github.com/carch-org/docs/tree/main/docs/:path",
183202
text: "GitHub पर इस पृष्ठ को संपादित करें",
184203
},
185-
204+
186205
nav: nav("hi", {
187206
home: "होम",
188207
guide: "गाइड",
189-
changelog: "चेंजलॉग"
208+
changelog: "चेंजलॉग",
190209
}),
191-
210+
192211
sidebar: sidebar("hi", {
212+
"getting-started": "शुरुआत करें",
193213
"getting-started/introduction": "परिचय",
194214
"getting-started/installation": "इंस्टॉलेशन",
215+
"reference": "संदर्भ",
195216
"reference/commands": "कमांड्स",
196217
"reference/overview-scripts": "स्क्रिप्ट्स का अवलोकन",
218+
"project": "परियोजना",
197219
"project/roadmap": "रोडमैप",
198220
"project/contributing": "योगदान",
199221
"project/codeofconduct": "आचार संहिता",
200222
"project/inspiration": "प्रेरणा",
201-
"project/contributors": "योगदानकर्ता"
223+
"project/contributors": "योगदानकर्ता",
202224
}),
203-
225+
204226
socialLinks: [
205227
{ icon: "telegram", link: "https://t.me/carchx" },
206228
{ icon: "discord", link: "https://discord.com/invite/8NJWstnUHd" },
207229
{ icon: "gmail", link: "mailto:[email protected]" },
208230
],
209-
231+
210232
footer: {
211233
message: "MIT लाइसेंस के तहत जारी।",
212234
copyright: "कॉपीराइट © 2025 हरि चालिसे",
213235
},
214-
215-
}
236+
},
216237
},
217238
},
218239

219240
themeConfig: {
220241
logo: "/carch.png",
221-
search: {
222-
provider: "local"
223-
},
242+
search: {
243+
provider: "local",
244+
},
224245
socialLinks: [
225246
{ icon: "telegram", link: "https://t.me/carchx" },
226247
{ icon: "discord", link: "https://discord.com/invite/8NJWstnUHd" },
227248
{ icon: "gmail", link: "mailto:[email protected]" },
228249
],
229-
}
250+
},
230251
};

0 commit comments

Comments
 (0)