Set up normal obsidian naming conventions

This commit is contained in:
Warwick 2024-01-24 12:28:19 +00:00
parent 6be120ede6
commit d7c432167f

View file

@ -20,4 +20,18 @@ require("obsidian").setup({
-- A map for custom variables, the key should be the variable and the value a function -- A map for custom variables, the key should be the variable and the value a function
substitutions = {}, substitutions = {},
}, },
note_id_func = function(title)
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 suffix
end,
}) })