-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
148 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import matter from 'gray-matter'; | ||
import { type Feature } from 'vitepress/dist/client/theme-default/components/VPFeatures.vue'; | ||
import { DocumentName, documentService } from './DocumentService'; | ||
import { IFeatureService } from './IFeatureService'; | ||
export class FeatureService implements IFeatureService { | ||
readonly linkText: string = 'Get started'; | ||
getFeaturesAsYaml(): string { | ||
return matter.stringify('', { features: this.getFeatures() }); | ||
} | ||
getArticleFeatureAsYaml(): string { | ||
return matter.stringify('', { features: this.getArticleFeature() }); | ||
} | ||
getArticleFeature(): Feature[] { | ||
const info = documentService.documentInfo['Articles' as DocumentName]; | ||
return [ | ||
{ | ||
title: 'Articles' as DocumentName, | ||
details: info.description, | ||
icon: info.icon, | ||
link: documentService.tryGetIndexLinkOfDocument('Articles' as DocumentName), | ||
}, | ||
]; | ||
} | ||
getFeatures(): Feature[] { | ||
const features: Feature[] = []; | ||
for (const key in documentService.documentInfo) { | ||
if (Object.prototype.hasOwnProperty.call(documentService.documentInfo, key)) { | ||
const documentInfo = documentService.documentInfo[key]; | ||
if ((key as DocumentName) !== 'Articles') | ||
features.push({ | ||
title: documentService.tryGetFormulaNameOfDocument(key as DocumentName), | ||
details: documentInfo.description, | ||
icon: documentInfo.icon, | ||
link: documentService.tryGetIndexLinkOfDocument(key as DocumentName), | ||
linkText: this.linkText, | ||
}); | ||
} | ||
} | ||
return features; | ||
} | ||
} | ||
|
||
export const featureService: IFeatureService = new FeatureService(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,21 @@ | ||
import * as File from '../shared/FileSystem'; | ||
import { DocumentInfo, DocumentName } from './DocumentService'; | ||
|
||
export interface IDocumentService { | ||
readonly documentInfo: DocumentInfo; | ||
physicalCount(): number; | ||
registeredCount(): number; | ||
physicalCountBy(f: (x: File.DirectoryInfo) => boolean): number; | ||
getIndexLinkOfDocument(name: DocumentName): string; | ||
tryGetIndexLinkOfDocument(name: DocumentName): string; | ||
get documentSrc(): File.DirectoryInfo; | ||
getMarkdownEntryFolder(name: DocumentName): File.DirectoryInfo; | ||
getDocumentEntryFolder(name: DocumentName): File.DirectoryInfo; | ||
registeredDocumentFolders(): File.DirectoryInfo[]; | ||
physicalDocumentFolders(): File.DirectoryInfo[]; | ||
tryGetFirstChapterFolderOfDocument(name: DocumentName): { | ||
firstFolder: File.DirectoryInfo; | ||
depth: number; | ||
}; | ||
tryGetFormulaNameOfDocument(name: DocumentName): string; | ||
isEmptyDocument(name: DocumentName): boolean; | ||
} | ||
export const documentMap = { | ||
'Csharp Design Patterns': '👾', | ||
'Modern CSharp': '🐱👤', | ||
Articles: '📰', | ||
Avalonia: '😱', | ||
Docker: '🐋', | ||
Git: '🐱', | ||
JavaScript: '😅', | ||
SQL: '📝', | ||
TypeScript: '⌨', | ||
VBA: '💩', | ||
Vue3: '⚡', | ||
} as const; | ||
export type DocumentName = keyof typeof documentMap; | ||
export type DocumentIcon = (typeof documentMap)[keyof typeof documentMap]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Feature } from 'vitepress/dist/client/theme-default/components/VPFeatures.vue'; | ||
|
||
export interface IFeatureService { | ||
getFeaturesAsYaml(): string; | ||
getArticleFeatureAsYaml(): string; | ||
getFeatures(): Feature[]; | ||
getArticleFeature(): Feature[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters