-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: erroneous title in daily note creation from template #496
base: main
Are you sure you want to change the base?
fix: erroneous title in daily note creation from template #496
Conversation
c6bdca2
to
2b5f928
Compare
@zDonik1 I'm confused why your alias ends up as a timestamp and not a formatted date. Can you share your config? In particular I'm curious what you have set for |
I don't have anything set for the Here is my entire config: require("obsidian").setup({
sort_by = "accessed",
disable_frontmatter = true,
workspaces = {
{
name = "personal",
path = "~/iCloudDrive/iCloud~md~obsidian/SecondBrain",
},
},
daily_notes = {
folder = "periodic_notes",
template = "daily_template.md",
},
templates = {
subdir = "templates",
time_format = "%X",
substitutions = {
["time:HH:mm:ss"] = function()
return os.date("%X")
end,
},
},
completion = {
nvim_cmp = true,
min_chars = 1,
},
new_notes_location = "current_dir",
note_id_func = function(title)
return title
end,
wiki_link_func = "use_path_only",
mappings = {
["gf"] = {
action = function()
return require("obsidian").util.gf_passthrough()
end,
opts = { noremap = false, expr = true, buffer = true },
},
["<leader>oh"] = {
action = function()
return require("obsidian").util.toggle_checkbox()
end,
opts = { buffer = true },
},
},
callbacks = {
---@param client obsidian.Client
---@param workspace obsidian.Workspace
post_set_workspace = function(client, workspace)
client.log.info("Changing directory to %s", workspace.path)
vim.cmd.cd(tostring(workspace.path))
end,
},
ui = {
hl_groups = {
ObsidianTodo = { bold = true, fg = mocha.peach },
ObsidianDone = { bold = true, fg = mocha.sapphire },
ObsidianRightArrow = { bold = true, fg = mocha.peach },
ObsidianTilde = { bold = true, fg = mocha.red },
ObsidianBullet = { bold = true, fg = mocha.sky },
ObsidianRefText = { underline = true, fg = mocha.mauve },
ObsidianExtLinkIcon = { fg = mocha.mauve },
ObsidianTag = { italic = true, fg = mocha.blue },
ObsidianHighlightText = { bg = mocha.flamingo },
},
},
}) |
I have done some tests, and it seems that the alias is getting set to a timestamp because lua doesn't understand what is going on when doing date printing. It seems like there is an extra obsidian.nvim/lua/obsidian/client.lua Lines 1895 to 1900 in a6b5e97
When I removed it, the alias was properly getting initialized. The only thing is that it still doesn't solve the issue with the wrong |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, the "-" must be a typo, but oddly it works fine on my computer. Fixed via 02f0136.
Anyway, I don't agree that in general the note's title should be its ID. But you can achieve the same result by setting daily_notes.alias_format
to the same formatting string as daily_notes.date_format
.
It doesn't have to be the Id. Obsidian replaces |
The
{{title}}
template parameter would get incorrectly replaced with the alias, which is a big number, presumably being the creation timestamp. The expected behavior is to replace it with filename.Example
The template:
# {{title}}
The created daily note (filename: 2024-03-16.md):
# 1710608450