Dataviewjs: getting metadata from files at `file.inlinks`

What I’m trying to do

I’m trying to use dataviewjs to recover metadata from files that are “inlinks” to files returned by a dataviewjs query.

Things I have tried

I’ve been able to successfully get the initial files that are link targets via the following:

dv.list(dv.pages('"food/dishes"'));

(As you can see, these are all the files in the “food/dishes” folder.)

Having obtained objects representing the metadata in those files, I now want to filter them by metadata contained in other files that link to the files returned by this starting query.

I can see from the output of the above that dv.pages('"food/dishes"') returns a data array of file objects that each have an inlink attribute. So, when I do

dv.list(dv.pages('"food/dishes"').file.inlinks);

I get the list of files linking to these pages that contain the metadata on which I wish to filter. Great!

But this is the point at which my understanding of dataviewjs seems to reach it’s limit.

It seems from the output I’m getting that dv.pages('"food/dishes"').file.inlinks returns links to the files I want, not what I actually need, which is a objects representing those files through which I can access their metadata.

For instance, each file in the inlinks has a date field in it’s metadata. But

dv.list(dv.pages('"food/dishes"').file.inlinks.file.date);

doesn’t return anything! (Evidently, dv.pages returns an array of objects, but dv.pages.file.inlinks just returns strings?)

Can you help me understand how to access the metadata at the files linked to by the links returned from dv.pages('"food/dishes"').file.inlinks?

Thanks!

1 Like

+1 I have the same question

dv.el("p", dv.current().file.inlinks)

return a list of links without metadata
image

dv.el("p", dv.pages('#trash/with_potential'))

return what i really want (metadata)

How can i transform list/array of links to array of dataview-metadata links?

It looks like I found a way out (where to dig)

You need to extract the path from each link, and then you can extract the metadata via dv.page (I found the solution here - DataviewJS Snippet Showcase - #135 by OllieT)

//dv.el("p", dv.current().file.inlinks)
dv.el("p", dv.page(dv.current().file.inlinks[1].path).file)