Hi,
I have found the following guide for getting the content of the current file:
const noteFile = this.app.workspace.getActiveFile(); // Currently Open Note
if(!noteFile.name) return; // Nothing Open
// Read the currently open note file. We are reading it off the HDD - we are NOT accessing the editor to do this.
let text = await this.app.vault.read(noteFile);
This code is created by Binny V A and published in txt.binnyvs.com.
How can I remove YAML frontmatter from this? Or is there another way to get the file content so that YAML is already filtered out?
In theory, I could try to come up with a regular expression that would strip away everything that is between two --- lines (with the first --- line being the very first thing in the file). I just don’t think it’s a good idea to do this kind of thing myself, as it can be errorprone, and I would guess Obsidian already does a split like this. I just don’t know if there is API access for it.
Thank you for your support!