DataviewJS Snippet Showcase

Well, I wanted to edit my reply above but am having problems editing it! Of course I realized only after I hit the “Reply” button that the following statement is just wrong:

As written, this will count every instance of a YAML field, even if it’s used multiple times in the same file

It seems to get very confused straight away if there are any indented keys in the frontmatter, omitting the indented key as well as both adjacent keys…I think? Clearly I have more testing to do. It will also only count one instance of a YAML field in a file, which is probably fine but contradicts what I said earlier. I would also like it to better handle nested keys, or other unusual YAML variations, but I don’t really know where to begin to learn about those–feel free to point me to any resources you know about funky YAML syntax that folks use in Obsidian!

I would really love it if the plugin exposed the keys themselves for regular queries, but I don’t know how many people suffer from my compulsion to tidy up YAML. I might have to teach myself to build a plugin just for auditing metadata in general!

If my editing functionality issue resolves, I will update my reply and remove this post to keep things uncluttered.

EDIT: of course it’s letting me edit this post and not the one above even though it hasn’t been that long (and didn’t let me edit even right after)…ugh.

3 Likes