Skip to content

Commit 53cde70

Browse files
committed
main
1 parent 1af3832 commit 53cde70

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

docs/services/SidebarService.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,25 @@ const solveSharpSign = (text: string) => {
1212
};
1313

1414
class SidebarService implements ISidebarService {
15-
private readonly base: string = `/${documentRoot().name}`;
15+
private getBase(name: DocumentName): string {
16+
if (Object.keys(documentService.skillDocInfo).includes(name)) {
17+
return `/${documentRoot().name}/Skill`;
18+
}
19+
if (Object.keys(documentService.readingDocInfo).includes(name)) {
20+
return `/${documentRoot().name}/Reading`;
21+
}
22+
return `/${documentRoot().name}`;
23+
}
1624
readonly documentService: IDocumentService = documentService;
1725
getMultipleSidebar(): DefaultTheme.SidebarMulti {
1826
const sidebar: DefaultTheme.SidebarMulti = {};
1927
for (const name of Object.keys(documentService.skillDocInfo)) {
20-
sidebar[`${this.base}/Skill/${name}/docs/`] = this.getSidebarOfDocument(name as DocumentName);
28+
sidebar[`${this.getBase(name as DocumentName)}/${name}/docs/`] = this.getSidebarOfDocument(
29+
name as DocumentName,
30+
);
2131
}
2232
for (const name of Object.keys(documentService.readingDocInfo)) {
23-
sidebar[`${this.base}/Reading/${name}/docs/`] = this.getSidebarOfDocument(
33+
sidebar[`${this.getBase(name as DocumentName)}/${name}/docs/`] = this.getSidebarOfDocument(
2434
name as DocumentName,
2535
);
2636
}
@@ -33,10 +43,11 @@ class SidebarService implements ISidebarService {
3343
text: solveSharpSign(name),
3444
items:
3545
name === 'Articles'
36-
? this.transformFolderToSidebarItem(markdownEntry, `${this.base}/${name}`).sort(
37-
(a, b) => gitTrackedDate(a.link!) - gitTrackedDate(b.link!),
38-
)
39-
: this.transformFolderToSidebarItem(markdownEntry, `${this.base}/${name}`),
46+
? this.transformFolderToSidebarItem(
47+
markdownEntry,
48+
`${this.getBase(name)}/${name}`,
49+
).sort((a, b) => gitTrackedDate(a.link!) - gitTrackedDate(b.link!))
50+
: this.transformFolderToSidebarItem(markdownEntry, `${this.getBase(name)}/${name}`),
4051
},
4152
];
4253
function gitTrackedDate(file: string): number {

0 commit comments

Comments
 (0)