Skip to content

Commit

Permalink
feature: allow grouping daily notes by date.
Browse files Browse the repository at this point in the history
  • Loading branch information
alpham committed Dec 14, 2024
1 parent ae1f76a commit 0d7c6f5
Showing 1 changed file with 17 additions and 3 deletions.
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 @@ -1914,9 +1921,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

0 comments on commit 0d7c6f5

Please sign in to comment.