Skip to content

Commit c923983

Browse files
committed
main
1 parent dc11430 commit c923983

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

docs/services/DocumentService.ts

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export const skillDocMap = {
1111
'Modern CSharp': { icon: '🦖', description: '' },
1212
Articles: { icon: '📰', description: 'Regular articles' },
1313
Avalonia: { icon: '😱', description: 'AvaloniaUI' },
14-
Docker: { icon: '🐳', description: 'Ultimate Docker' },
14+
Docker: { icon: '🐳', description: '' },
1515
Git: { icon: '😸', description: 'Git mastery' },
16-
JavaScript: { icon: '😅', description: '' },
16+
JavaScript: { icon: '😅', description: 'Not funny' },
1717
// SQL: { icon: '🦭', description: '' },
18-
TypeScript: { icon: '🤯', description: '' },
18+
TypeScript: { icon: '🤯', description: 'Type wizard I will become...' },
1919
// VBA: { icon: '💩', description: 'VBA for excel' },
2020
// Vue3: { icon: '⚡', description: '' },
2121
'Unsafe CSharp': { icon: '😎', description: 'Entering the danger zone...' },
@@ -24,15 +24,17 @@ export const skillDocMap = {
2424
// description: 'Make your own nvim color scheme using lua.',
2525
// },
2626
Bash: { icon: '🐢', description: 'Shebang!' },
27-
'Regular Expression': { icon: '🐫', description: 'Memory lossss for every 6 months' },
27+
'Regular Expression': { icon: '🐫', description: "Can't remember it for 2 days" },
2828
Nix: { icon: '❄', description: 'Reproduce freedom' },
2929
'Entity Framework Core': { icon: '🗿', description: '' },
3030
'HTML & CSS': { icon: '😬', description: '' },
31-
PowerShell: { icon: '🐚', description: '' },
32-
Lua: { icon: '🌝', description: '' },
31+
PowerShell: { icon: '🐚', description: 'A pretty solid shell' },
32+
Lua: { icon: '🌝', description: 'I wish lua could have JavaScript syntax' },
3333
} as const satisfies DocumentInfo;
3434

35-
const readingDocMap = {} as const satisfies DocumentInfo;
35+
const readingDocMap = {
36+
Test: { icon: '🚗', description: 'this is a test' },
37+
} as const satisfies DocumentInfo;
3638

3739
export type DocumentName = keyof typeof skillDocMap | keyof typeof readingDocMap;
3840

@@ -80,21 +82,32 @@ class DocumentService implements IDocumentService {
8082
}
8183
}
8284

85+
/**
86+
* @param name - nameof document
87+
* @returns the very parent folder of the document
88+
*/
8389
getDocumentEntryFolder(name: DocumentName): FileSystem.DirectoryInfo {
8490
if (name === 'Articles') {
8591
return this.articleDocParent;
8692
}
87-
const ret = this.registeredDocumentFolders().find(x => x.name === name);
93+
94+
let src: FileSystem.DirectoryInfo;
95+
96+
if (Object.keys(skillDocMap).includes(name)) {
97+
src = this.skillDocParent;
98+
} else if (Object.keys(readingDocMap).includes(name)) {
99+
src = this.readingDocParent;
100+
}
101+
102+
const ret = src.getDirectories().find(x => x.name === name);
88103
if (!ret) throw new Error(`Document entry of "${name}" not found.`);
89104
return ret;
90105
}
91106

92-
registeredDocumentFolders(): FileSystem.DirectoryInfo[] {
93-
return this.skillDocParent
94-
.getDirectories()
95-
.filter(x => Object.keys(skillDocMap).includes(x.name));
96-
}
97-
107+
/**
108+
* @param name - nameof the document
109+
* @returns docs folder of the document
110+
*/
98111
getMarkdownEntryFolder(name: DocumentName): FileSystem.DirectoryInfo {
99112
const ret = this.getDocumentEntryFolder(name)
100113
.getDirectories()
@@ -103,6 +116,11 @@ class DocumentService implements IDocumentService {
103116
return ret;
104117
}
105118

119+
/**
120+
* find a entry file location for given document name
121+
* @param name - nameof document
122+
* @returns relative path to the document file
123+
*/
106124
tryGetIndexLinkOfDocument(name: DocumentName): string {
107125
if (this.isEmptyDocument(name)) return '/';
108126

@@ -112,8 +130,15 @@ class DocumentService implements IDocumentService {
112130
};
113131

114132
const shouldSolveSharpSign = (name: DocumentName) => name.includes('#');
133+
134+
let src: FileSystem.DirectoryInfo;
135+
if (Object.keys(skillDocMap).includes(name)) {
136+
src = this.skillDocParent;
137+
} else if (Object.keys(readingDocMap).includes(name)) {
138+
src = this.readingDocParent;
139+
}
115140
const markdownEntry = this.getMarkdownEntryFolder(name);
116-
let linkContext = `${this.skillDocParent.name}/${name}/`;
141+
let linkContext = `document/${src.name}/${name}/`;
117142

118143
if (markdownEntry.getFiles().length) {
119144
const file = Enumerable.from(markdownEntry.getFiles())

0 commit comments

Comments
 (0)