Forgot to mention… if you want to know if the file is a folder before you add the menu item (so it won’t appear on regular files), you can use if (file.children) menu.addItem()...
. If you want to do additional checks, like whether it already has a folder note, you can, but they have to be synchronous with no async/await. (So you can use e.g. app.vault.getAbstractFileByPath()
to test for a file’s existence, but not .exists()
, because the former is synchronous and the latter is not.)