I need to rewrite my existing plugin, and it looks like YAML and frontmatter is dealt with in new ways. I’m wondering if there is now an API that will let me a) read a file and extract the YAML and markdown as separate objects, and b) a safe and consistent way to construct and write YAML properties back to a new file?
Just for more info, what I would really like is something like:
- getYamlFrontmatter(data:string) - pulls out and parses the Yaml frontmatter from a note
- getBody(data:string) - returns just the body of the note without the frontmatter
- writeNote(path:string, frontmatter: any/[String:any], body:string)
I can make my own versions of all of these, but there’s always fiddly edge cases, and it’s clearly something Obsidian is doing internally, so I’m hoping for a nicer way to do things.
You can find all the functions here:
If you search for “frontmatter”, “read”, and “write” you can find those three functions you mention above. To write the frontmatter is processFrontmatter
Sorry I’m on mobile so can’t pull them each out.
Thanks!