mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
refactor(server/utils): simplify getNoteTitle
This commit is contained in:
parent
c3587ad536
commit
65be2cf048
@ -182,15 +182,9 @@ export function removeTextFileExtension(filePath: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getNoteTitle(filePath: string, replaceUnderscoresWithSpaces: boolean, noteMeta?: NoteMeta) {
|
export function getNoteTitle(filePath: string, replaceUnderscoresWithSpaces: boolean, noteMeta?: NoteMeta) {
|
||||||
if (noteMeta?.title) {
|
if (noteMeta?.title) return noteMeta.title;
|
||||||
return noteMeta.title;
|
const basename = path.basename(removeTextFileExtension(filePath));
|
||||||
} else {
|
return replaceUnderscoresWithSpaces ? basename.replace(/_/g, " ").trim() : basename;
|
||||||
const basename = path.basename(removeTextFileExtension(filePath));
|
|
||||||
if (replaceUnderscoresWithSpaces) {
|
|
||||||
return basename.replace(/_/g, " ").trim();
|
|
||||||
}
|
|
||||||
return basename;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function timeLimit<T>(promise: Promise<T>, limitMs: number, errorMessage?: string): Promise<T> {
|
export function timeLimit<T>(promise: Promise<T>, limitMs: number, errorMessage?: string): Promise<T> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user