-
when you create a file it uses random name. you have to use .md with the name to use heading as file name. how can I create a file with heading name as file name without writing .md in links? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hey @shawaman, in your configuration you can specify a note_id_func = function(title)
-- Create note IDs in a Zettelkasten format with a timestamp and a suffix.
-- In this case a note with the title 'My new note' will be given an ID that looks
-- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md'
local suffix = ""
if title ~= nil then
-- If title is given, transform it into valid file name.
suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
else
-- If title is nil, just add 4 random uppercase letters to the suffix.
for _ = 1, 4 do
suffix = suffix .. string.char(math.random(65, 90))
end
end
return tostring(os.time()) .. "-" .. suffix
end, If you literally want the title/heading as the note name you could simply return |
Beta Was this translation helpful? Give feedback.
-
It's working fine now with the following. note_id_func = function(title)
local suffix = ""
if title ~= nil then
suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
else
for _ = 1, 4 do
suffix = suffix .. string.char(math.random(65, 90))
suffix = tostring(os.time()) .. "-" .. suffix
end
end
return suffix
end, |
Beta Was this translation helpful? Give feedback.
Hey @shawaman, in your configuration you can specify a
note_id_func
. This is just a Lua function that's responsible for determining the ID/filename of new notes based on the title. The function I use personally looks like this: