So to resummarise the summary:
- The script will be used in potentially many folders, and you’ll insert it into the “index” file of that folder
- In such a folder,
link will point to that index file, and you don’t want them to show up in the query
- Outside of such a folder, a
pink reference might link to the current folders index, and in that case it should show
This bargains for a slightly different solution, that when it’s just in one folder. So my new suggestion is to use a
dv.view() script, which you’ll reference the same way in any of your index notes (in whatever folder you’ll place it in). This way, if you need to change something, you change it one place, and all the various “index” notes gets the update at the same time.
The dv.view script I used when testing
f54318LinkAndPink.js.zip (422 Bytes)
Uncompress the file above into a dedicated folder for your
dv.view() scripts. In my test vault, that is the
_js folder. Feel free to change it to whatever you like, and be sure to change the references below to match that folder.
You’ll most likely need to adapt it a little to your case, like possibly remove the
FROM #f54318 and change what is the output in the table. If you want a list output, more changes needs to be done, but please come back to me if that is the case.
The main point in that script is either way the
WHERE clause, which is like this:
file.path != this.file.path AND
( file.folder = this.file.folder AND !link)
( file.folder != this.file.folder AND pink AND pink.file.path = this.file.path )
The explanation is as follows:
- First of all exclude the current index file from the list
- Now match either of the following conditions:
- If we’re looking at files in the same folder,
file.folder = this.file.folder, then only pull out files which don’t have the
- If we’re looking at files in another folder,
file.folder != this.file.folder, then check if that file has a
pink field, and if it does, check whether that refers back to this index file
In my test setup, I’ve included the following in both
PS: If you can’t get the syntax correct for your query within the
dv.view() script, please post the query which has the output you like, and I’ll try to give you a better version.
PPS: Note that the view script file needs to end in
.js, and it needs to be a clean text file for it to work. I’ve added the
plaintext plugin, and configured in so that I can also see
.js files in my vault. Another way to do this, is to use a text editor (like VS Code) outside of Obsidian.