Dataview.js markdown link filter

Hi,
i would like to filter an dataview.js query. I have an inline [Related:: [[Site]]] on sites and i would like to crawl all sites with this.
This is my code:

dv.table(
	["Title"], 
	dv.pages()
	.where(b => b.Related == "[[Site]]")
        .map(b => [b.title]))

0 elements are displayed.
What am I doing wrong?

Investigation strategy:
Pick one or a few site notes manually and display their “Related” field in your table. Does it look like what you expect? Do you need to use something like includes(...) instead of exact equality? Example table for investigation:

dv.table(
["Title", "Related"], 
dv.pages('"path/to/a/folder/or/file/to/test/on"')
.map(b => [b.title, b.Related])
);

Hopefully that’ll help you find out what isn’t behaving the way it is supposed to!

This is the solution:

dv.table(
	["Title"], 
	dv.pages()
        .where(b => String(b.Related).includes("MOC1"))
        .map(b => [b.title]))

Now it is possible to create map of contents automatically. Simply put on each page that should be displayed with in the dataview a ‘Related:: [[MOC1]], [[MOC2]]’.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.