Skip to content

Commit

Permalink
solve sidebar name
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpchen committed Apr 12, 2024
1 parent 1a1a194 commit 8aaaf9c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions docs/services/SidebarService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { DirectoryInfo, FileInfo, Path, documentRoot } from '../shared/FileSyste
import { DocumentName, documentMap, documentService } from './DocumentService';
import { IDocumentService } from './IDocumentService';
import { ISidebarService } from './ISidebarService';

const solveSharpSign = (text: string) => {
if (text.includes('sharp')) return text.replace('sharp', '#');
if (text.includes('Sharp')) return text.replace('Sharp', '#');
return text;
};
class SidebarService implements ISidebarService {
private readonly base: string = `/${documentRoot().name}`;
readonly documentService: IDocumentService = documentService;
Expand All @@ -18,17 +22,12 @@ class SidebarService implements ISidebarService {
const markdownEntry = this.documentService.getMarkdownEntryFolder(name as DocumentName);
return [
{
text: name,
text: solveSharpSign(name),
items: this.transformFolderToSidebarItem(markdownEntry, `${this.base}/${name}`),
},
];
}
transformFolderToSidebarItem(folder: DirectoryInfo, base: string): DefaultTheme.SidebarItem[] {
const solveSharpSign = (text: string) => {
if (text.includes('sharp')) return text.replace('sharp', '#');
if (text.includes('Sharp')) return text.replace('Sharp', '#');
return text;
};
const subs = folder.getDirectories();
// load files in this folder
let items: DefaultTheme.SidebarItem[] = folder.getFiles().length
Expand Down

0 comments on commit 8aaaf9c

Please sign in to comment.