mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
fix(server/utils): fix potentially "empty looking" title from getNoteTitle
when the noteMeta title consists of just spaces, it will fall back to "normal" handling again → instead of showing " " as title, which would be perceived as "empty"
This commit is contained in:
parent
46f28f4f09
commit
6e5e6989ed
@ -182,7 +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) return noteMeta.title;
|
const trimmedNoteMeta = noteMeta?.title?.trim();
|
||||||
|
if (trimmedNoteMeta) return trimmedNoteMeta;
|
||||||
|
|
||||||
const basename = path.basename(removeTextFileExtension(filePath));
|
const basename = path.basename(removeTextFileExtension(filePath));
|
||||||
return replaceUnderscoresWithSpaces ? basename.replace(/_/g, " ").trim() : basename;
|
return replaceUnderscoresWithSpaces ? basename.replace(/_/g, " ").trim() : basename;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user