Skip to content
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

feature: allow grouping daily notes by date. #792

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions lua/obsidian/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ Client.set_workspace = function(self, workspace, opts)
end

if self.opts.daily_notes.folder ~= nil then
local daily_notes_subdir = self.dir / self.opts.daily_notes.folder
---@type string
local folder = self.opts.daily_notes.folder

---@diagnostic disable-next-line: need-check-nil
if folder:find "%%" then
folder = tostring(os.date(folder, os.time()))
end
local daily_notes_subdir = self.dir / folder
daily_notes_subdir:mkdir { parents = true, exists_ok = true }
end

Expand Down Expand Up @@ -1924,9 +1931,16 @@ Client.daily_note_path = function(self, datetime)
local path = Path:new(self.dir)

if self.opts.daily_notes.folder ~= nil then
---@type obsidian.Path
---@type string
local folder = self.opts.daily_notes.folder

---@diagnostic disable-next-line: need-check-nil
if folder:find "%%" then
folder = tostring(os.date(folder, datetime))
end

---@diagnostic disable-next-line: assign-type-mismatch
path = path / self.opts.daily_notes.folder
path = path / folder
elseif self.opts.notes_subdir ~= nil then
---@type obsidian.Path
---@diagnostic disable-next-line: assign-type-mismatch
Expand Down
Loading