I am trying to create a ‘dynamic’ breadcrumb, using dataview, that will allow me to move back up a related file chain. To do this, I need to use a YAML value in one file to access YAML data in another file.
In my notes, I have YAML metadata defined as:
project: Project A
Project A is a file in my vault, and within the project file, I have YAML as:
department: Department X
I think I have working dataviewjs code, as I can get the correct values displayed in the console, but I can’t seem to get them onto the rendered page. Here is what I have:
let relPage = dv.page(dv.current().project) //get the page array for the referenced project
// console.log(relPage)
let dept = relPage.department //get the value of 'department'
// console.log(dept)
In the page I have tried:
$=dv.current().dept but this dives me no output =this.dept also gives me no output
I’m probably doing something really silly and obvious, but I can’t see it.
I think the problem might be trying to embed a link in the YAML metadata. I wasn’t able to get Dataview to recognize a linked page in the metadata.
However, when I switched to using a Dataview field for the project reference it worked fine. (I put the Project field inside a comment so it would be invisible, but that’s not required.)
So, I can make it work. But, for ease of reading I’d like to define things in dataviewjs block and then be able to structure my ‘breadcrumbs’ using the variable names.
What I can’t figure out is why I can’t output a variable value defined in a dataviewjs block.