obsidian.nvim icon indicating copy to clipboard operation
obsidian.nvim copied to clipboard

Create a note without id or -

Open barcell1 opened this issue 1 year ago • 2 comments

🚀 The feature, motivation and pitch

i like to create a note and obsidian didnt transform the title. Like [[my new note]] will become "my new note.md" I tried to tweak the functions in config but dont have the intelligence to make work without errors

Alternatives

No response

Additional context

No response

barcell1 avatar Oct 18 '24 15:10 barcell1

You can customize the created note path in:

  -- Optional, customize how note file names are generated given the ID, target directory, and title.
  ---@param spec { id: string, dir: obsidian.Path, title: string|? }
  ---@return string|obsidian.Path The full path to the new note.
  note_path_func = function(spec)
    -- This is equivalent to the default behavior.
    local path = spec.dir / tostring(spec.id)
    return path:with_suffix(".md")
  end,

To achieve what you want, add this in the configs:

  -- Optional, customize how note file names are generated given the ID, target directory, and title.
  ---@param spec { id: string, dir: obsidian.Path, title: string|? }
  ---@return string|obsidian.Path The full path to the new note.
  note_path_func = function(spec)
    local path = spec.dir / tostring(spec.title)
    return path:with_suffix(".md")
  end,

Note: This will changes just the filename not the id, the id by default will be timestamp-####, to change it check: Random ID as note name instead of the actual note name · Issue #756 · epwalsh/obsidian.nvim · GitHub.

raphaeltannous avatar Oct 21 '24 11:10 raphaeltannous

thanks, it did work. But now how do i prevent to it not create a alias with the same name of my title ?

since my file name already have the name that i want, dont need to the alias have the same name

barcell1 avatar Nov 02 '24 15:11 barcell1