tokenshift / obsidian-page-gallery

Generates a gallery based on selected page contents.
MIT License
64 stars 2 forks source link

using "[[]]" in queries doesn't work #47

Closed sseeland closed 1 year ago

sseeland commented 1 year ago

I want to display a page gallery of all the pages that link to the current page (filtered by tag, but that's irrelevant).

In DataView, the simple query "LIST FROM [[]] and #my-tag" works just fine, but when I use that in page-gallery it doesn't, for some reason. If I change the query to "from: '[[MyPage]] and #my-tag'" it works, but that means I have to enter the page name manually and it will break on renames.

The same is true for "where". If I put "where: contains(myKey, [[]])" it never works, but "where: contains(myKey, [[MyPage]])" works fine.

Would be great if that could be fixed as it makes it so much easier to write reusable galleries.

tokenshift commented 1 year ago

The from clause issue should be fixed in 0.7.3. I haven't found a way to get self-links working in the where clause or other fields (sortBy, fields, groupBy have this issue as well), since there doesn't seem to be a way to pass the origin page into the DataviewApi#evaluate function right now; it seems to be using a default LinkHandler with "" as its base path, and I can't find a good way to override/replace that without copying a bunch of internal Dataview code. I'm going to open an issue on https://github.com/blacksmithgu/obsidian-dataview to see if the evaluate function can be updated to support different origin pages. I'll keep this issue open and link it to that one.

tokenshift commented 1 year ago

Opened https://github.com/blacksmithgu/obsidian-dataview/issues/1930 Tentative PR: https://github.com/blacksmithgu/obsidian-dataview/pull/1931

tokenshift commented 1 year ago

As a workaround, you can use this in the where, sortBy, fields, and groupBy settings to refer to the current page; so this query should also work: where: contains(myKey, this.file.link) .

sseeland commented 1 year ago

Oh nice, thanks!