obsidian-developer-docs
obsidian-developer-docs copied to clipboard
Should there be a sample for processFrontMatter?
https://docs.obsidian.md/Reference/TypeScript+API/filemanager/processFrontMatter
On the page its not clear how exactly to read or write property values with it. I think this code sample might help
// get the current file and check if the "Date Completed" property is blank (but also present). If so then set it to the current time with MomentJS
let file = app.workspace.getActiveFile();
await app.fileManager.processFrontMatter(file, (fm) => {
if (fm["Date Completed"] === null) {
fm["Date Completed"] = moment().format("YYYY-MM-DD");
}
});