Hello, here I am looking again at possibly trying to learn Obsidian plugin development. It’s a slog! Part of what I’ll need to do is get a list of all task items in my vault, which I can modify and “put back” somehow according to my vague plans. See how little I know?
In the process, I was looking at a related plugin (task-archiver) and noticed that it called the obsidian API function parseFrontMatterAliases(). I have no idea what this function does. So I looked around and found only this:
As impressive as that link makes things look, the documentation for this function is pretty sparse. I see it takes a “frontmatter” argument. But there is no explanation of what this might be. I have only my intuition that it represent the frontmatter of a file somehow. Is it a string? Where would I get this string from?
Frontmatter is the YAML-formatted header meta-data sometimes found at the front (top) of the note. This meta-data is delineated by lines containing only three hyphens. This data takes the form of key-value pairs where the value may be a list.
As to the specific API call you ask about, I assume it will return the value(s) of the ‘alias:’ key. I.E.: if the front matter contains a line
Blockquote
alias: [ foo, bar, baz ]
Then parseFrontMatterAliases would return the array [ “foo”, “bar”, “baz” ].
Your assumption is perhaps right, although I also took a guess and I don’t know how to determine which guess could be right. I wonder, is there an authoritative source we could check to see? Or do developers generally just try stuff until it works? I’d like to hear from a plugin developer about this.
Frontmatter is simply a JavaScript object. You can get the frontmatter of a myTFile of type TFile using this.app.metadataCache.getFileCache(myTFile)?.frontmatter.
Thank you! Can I ask, how did you come by this knowledge? By playing around in the developer’s console and using your instincts? Asking other developers? A combination? Thanks!