What I’m trying to do
I am trying to create a table in dataviewjs where one of the columns displays a list of tags pulled from the outlinks of a file.
Things I have tried
I have already made the table in base dataview.
TABLE file.outlinks as Parts, join(file.outlinks.file.tags) as “Recipe Types”
FROM “New Plant Test”
WHERE contains(file.name,“Plant”)
I am essentially trying to convert the above table into dataviewjs but cannot figure out how to do the equivalent of file.outlinks.file.tags
In DataviewJS you need to resolve each link to a page object first. Roughly:
const pages = dv.pages("New Plant Test")
.where(p => p.file.name.includes("Plant"));
dv.table(["Parts", "Recipe Types"], pages.map(p => {
const outPages = p.file.outlinks
.map(l => dv.page(l.path))
.filter(Boolean);
return [
p.file.outlinks,
outPages.flatMap(op => op.file.tags ?? []).join(", ")
];
}));
The important bit is dv.page(link.path): file.outlinks is just link data, not the linked page metadata yet.
That worked!!
I did think the problem would be something along those lines but I’m new to dataview and I didn’t know how to go about fixing it. Thank you for your help!