Dataviewjs: Check if list of links in frontmatter contains link to current note

In my frontmatter, I have defined a list of “areas” a note can belong to:

creation_date: 2023-03-02
  - "[[area1]]"
  - "[[area2]]"

In the notes for the respective areas, I want to write a query that lists all notes belonging to that area:

	["Link", "Areas"], 
		.filter(p => (p.areas && p.areas.contains(dv.current()
		.map(b => [,
			b.areas ? (b.areas.length ? b.areas.join(", ") : b.areas) : b.areas

However, I cannot get the second part of the filter to work. Does it have something to do that the links in the YAML frontmatter have quotation marks around them? They also don’t show up in the outlinks.

Searching through other topics in the forum, I found a solution here.

Instead of writing p.areas.contains(...), I needed to write dv.array(p.areas).includes(...). I’d like to understand why this is the case, but for now I’m just happy it works.

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