The trickery to this is that now we’re able to process the items of the lists more easily, and can work the metadata of the lists. Please do execute each of them from within one of the daily notes to follow the progress, as you’ll hopefully also then see how to develop similar queries.
```dataview
TABLE WITHOUT ID item.text, item
FLATTEN file.lists as item
WHERE file.name = "Log"
```
(Update: Removed typo with this.file.name
to file.name
)
This will list each of the items of the lists from the file Log.md
, and in addition it’ll list all the metadata associated with each item. In that lists you’ll see the outlinks
item which is the one we’re particularly interested in. One vital portion of this query is that I’m using FLATTEN
on the lists, to split them into the separate items of the list.
```dataview
TABLE WITHOUT ID item.text, item.outlinks
FLATTEN file.lists as item
WHERE file.name = "Log"
```
(Update: Removed typo with this.file.name
to file.name
)
Now the query shows the “list” of outlinks, which in our case should be only one, and we’ll enforce that using the [0]
in the next query, and that link we can ensure is equal to the current link, which is then our answer. Let us switch over to a LIST
in the same step.
```dataview
LIST WITHOUT ID item.text
FLATTEN file.lists as item
WHERE file.name = "Log"
AND this.file.link = item.outlinks[0]
```
Now we’ve lost the extra column, and we’re limiting the output to just those actually linking to our example. A slightly different, and possibly more robust way to write the outlink test is the following:
```dataview
LIST WITHOUT ID item.text
FLATTEN file.lists as item
WHERE file.name = "Log"
AND contains(item.outlinks, [[]])
```
This would allow for multiple outlinks in your lists, and it uses the [[]]
to denote the current file link.
Finally, if you don’t want the date to show you could add some regex to the output to hide the link part in the daily note. So here is another version (showing multiple paths to achieve your goal):
```dataview
LIST WITHOUT ID text
FLATTEN file.lists as item
FLATTEN regexreplace(item.text, "^\[\[.*?\]\]", "") as text
WHERE file.name = "Log"
AND contains(item.outlinks, this.file.link)
```
The regex matches from the start of the text, ^
, two literal square brackets, \[\[
, before the shortest amount of random characters, .*?
, before two literal square brackets, \]\]
. If found within text.item
, it replaces the match with nothing, ""
. In essence, this removes any link at the start of the text.