Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
TwIStOy committed Apr 23, 2024
1 parent f1ed850 commit 0234616
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lua/dotvim/pkgs/editor/plugins/obsidian.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,18 @@ return {
},
use_advanced_uri = true,
mappings = {},
note_id_func = function(_)
return ("%0x-%04x-%4x"):format(
os.time(),
math.random(0, 0xffff),
math.random(0, 0xffff)
)
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 tostring(os.time()) .. "-" .. suffix
end,
note_frontmatter_func = function(note)
local out = {
Expand Down

0 comments on commit 0234616

Please sign in to comment.