Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should there be a sample for processFrontMatter? #84

Open
YousufSSyed opened this issue Nov 10, 2023 · 0 comments
Open

Should there be a sample for processFrontMatter? #84

YousufSSyed opened this issue Nov 10, 2023 · 0 comments
Assignees

Comments

@YousufSSyed
Copy link

YousufSSyed commented Nov 10, 2023

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");
    }
});
@joethei joethei self-assigned this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants