@@ -276,7 +276,7 @@ Client.templates_dir = function(self, workspace)
276
276
return nil
277
277
end
278
278
279
- --- Determines whether a note's frontmatter is managed by obsidian.nvim.
279
+ --- Determines whether a note's frontmatter is created by obsidian.nvim.
280
280
---
281
281
--- @param note obsidian.Note
282
282
---
@@ -295,10 +295,38 @@ Client.should_save_frontmatter = function(self, note)
295
295
296
296
if not note :should_save_frontmatter () then
297
297
return false
298
- elseif type (self .opts .disable_frontmatter ) == " boolean" then
299
- return not self .opts .disable_frontmatter
300
- elseif type (self .opts .disable_frontmatter ) == " function" then
301
- return not self .opts .disable_frontmatter (tostring (self :vault_relative_path (note .path , { strict = true })))
298
+ elseif type (self .opts .disable_frontmatter_creation ) == " boolean" then
299
+ return not self .opts .disable_frontmatter_creation
300
+ elseif type (self .opts .disable_frontmatter_creation ) == " function" then
301
+ return not self .opts .disable_frontmatter_creation (tostring (self :vault_relative_path (note .path , { strict = true })))
302
+ else
303
+ return true
304
+ end
305
+ end
306
+
307
+ --- Determines whether a note's frontmatter can be updated obsidian.nvim
308
+ ---
309
+ --- @param note obsidian.Note
310
+ ---
311
+ --- @return boolean
312
+ Client .should_update_frontmatter = function (self , note )
313
+ -- Check if the note is a template.
314
+ local templates_dir = self :templates_dir ()
315
+ if templates_dir ~= nil then
316
+ templates_dir = templates_dir :resolve ()
317
+ for _ , parent in ipairs (note .path :parents ()) do
318
+ if parent == templates_dir then
319
+ return false
320
+ end
321
+ end
322
+ end
323
+
324
+ if not note :should_save_frontmatter () then
325
+ return false
326
+ elseif type (self .opts .disable_frontmatter_update ) == " boolean" then
327
+ return not self .opts .disable_frontmatter_update
328
+ elseif type (self .opts .disable_frontmatter_update ) == " function" then
329
+ return not self .opts .disable_frontmatter_update (tostring (self :vault_relative_path (note .path , { strict = true })))
302
330
else
303
331
return true
304
332
end
@@ -1901,7 +1929,7 @@ end
1901
1929
---
1902
1930
--- @return boolean updated If the the frontmatter was updated.
1903
1931
Client .update_frontmatter = function (self , note , bufnr )
1904
- if not self :should_save_frontmatter (note ) then
1932
+ if not self :should_update_frontmatter (note ) then
1905
1933
return false
1906
1934
end
1907
1935
0 commit comments