feat: rename file on save when title slug doesn't match filename
When Cmd+S is pressed, after saving content, checks if the note's title slug differs from its current filename. If so, triggers rename_note to update the file on disk, tabs, breadcrumbs, and wikilinks. Adds needsRenameOnSave() utility with tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,11 @@ export function slugify(text: string): string {
|
||||
return result || 'untitled'
|
||||
}
|
||||
|
||||
/** Check if a note's filename doesn't match the slug of its current title. */
|
||||
export function needsRenameOnSave(title: string, filename: string): boolean {
|
||||
return `${slugify(title)}.md` !== filename
|
||||
}
|
||||
|
||||
/** Generate a unique "Untitled <type>" name by checking existing entries and pending names. */
|
||||
export function generateUntitledName(entries: VaultEntry[], type: string, pending?: Set<string>): string {
|
||||
const baseName = `Untitled ${type.toLowerCase()}`
|
||||
|
||||
Reference in New Issue
Block a user