obsidian-api icon indicating copy to clipboard operation
obsidian-api copied to clipboard

Bug: processFrontMatter does not work if callback deletes all keys

Open AndyEveritt opened this issue 1 year ago • 0 comments

https://docs.obsidian.md/Reference/TypeScript+API/FileManager/processFrontMatter

[!NOTE] I am not a JS/TS developer so my terminology is likely wrong

Steps to reproduce:

await this.app.fileManager.processFrontMatter(
  sharedFile.file,
  (frontmatter) => {
    // Remove the shared link
    delete frontmatter["link"];
  }

taken from project

if link is the only field in the frontmatter object then this will not do anything. If there are other fields then the link field is correctly deleted

Expected Behaviour

The provided code would delete the link field from the frontmatter regardless of is it leaves the frontmatter empty

AndyEveritt avatar Apr 21 '24 18:04 AndyEveritt