I have a bunch of books in my Obsidian, and I used to have the “author” in YAML, like this:
author: Bob Smith
I’ve since changed it to be in the main content, like this:
Author:: Bob Smith
For some queries it continues to work fine, but for others it doesn’t. This is the one that is killing me. In the note named “Bob Smith”, I have this:
WHERE contains(Author, this.file.name)
SORT file.name ASC
It was great, because I could drop that snippet on every author page and it would pull in a list of their books to their page.
It worked when “author” was in YAML, but no longer works with the new way I’m showing the author name. What am I missing here?
That’s odd, your query is working fine for me. Did you perhaps forget the #book tag on your page?
Ok, I see the difference now, but still not understanding why it’s broken.
Mine is actually formatted where Bob Smith is linked, so it’s:
Author:: [[Bob Smith]]
Unlinking it solves the issue, but I would think that the “contains” part of the query would look inside of the brackets.
If I make the where statement:
WHERE contains(Author, [[Bob Smith]])
it works, but I’d rather keep it with the “this.file.name” piece in there for simplicity.
For anyone else that comes across this, I think I solved it.
All of that work, and I really just need to change this.file.name to this.file.link and it matches up perfectly!
I appreciate your help Craig.
A slight addendum. If a book has two authors, it doesn’t work. Like this:
Author:: [[Bob Smith]] and [[Jane Doe]]
However, in that case (for whatever reason), the old “this.file.name” does work. I don’t understand. Regardless, this covers both cases for me:
WHERE contains(author, this.file.name) OR contains(author, this.file.link)
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.