minor refractor

This commit is contained in:
js0ny 2025-10-21 15:36:02 +01:00
parent 679f5bea9d
commit 1b99070718
22 changed files with 248 additions and 298 deletions

View file

@ -1,12 +1,11 @@
local uuid = function()
local template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function(c)
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
return string.format('%x', v)
local template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
return string.gsub(template, "[xy]", function(c)
local v = (c == "x") and math.random(0, 0xf) or math.random(8, 0xb)
return string.format("%x", v)
end)
end
return {
"obsidian-nvim/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit
@ -83,45 +82,47 @@ return {
yesterday = function()
return os.date("%Y-%m-%d", os.time() - 86400)
end,
uuid = uuid()
uuid = uuid(),
},
},
---@return table
note_frontmatter_func = function(note)
-- Add the title of the note as an alias.
if note.title then
note:add_alias(note.title)
end
-- Force to use UUID as the note id.
local note_id
if note.metadata then
note_id = note.id
else
note_id = uuid()
end
local out = {
id = note_id,
aliases = note.aliases,
tags = note.tags,
title = note.id,
date = os.date(
"%Y-%m-%dT00:00:00"),
}
-- `note.metadata` contains any manually added fields in the frontmatter.
-- So here we just make sure those fields are kept in the frontmatter.
if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then
for k, v in pairs(note.metadata) do
out[k] = v
frontmatter = {
func = function(note)
-- Add the title of the note as an alias.
if note.title then
note:add_alias(note.title)
end
end
-- Force to update mtime.
out.mtime = os.date("%Y-%m-%dT%H:%M:%S")
return out
end,
-- Force to use UUID as the note id.
local note_id = uuid()
if note.metadata.id == nil then
note_id = uuid()
else
note_id = note.metadata.id
end
local out = {
-- id = note_id,
aliases = note.aliases,
tags = note.tags,
title = note.id,
-- date = os.date("%Y-%m-%dT00:00:00"),
-- mtime = os.date("%Y-%m-%dT%H:%M:%S"),
}
-- `note.metadata` contains any manually added fields in the frontmatter.
-- So here we just make sure those fields are kept in the frontmatter.
if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then
for k, v in pairs(note.metadata) do
out[k] = v
end
end
-- Force to update mtime.
out.mtime = os.date("%Y-%m-%dT%H:%M:%S")
return out
end,
},
daily_notes = {
folder = "_Global/Periodic",
date_format = "%Y-%m-%d",