find-citations
DataviewJS Query
#981
-
Let's assume we have two notes: Anywhere in the body of What I'm trying to do is write a query that will find "the set of all notes which have a // uncomment the below to test in-line. this code is going into a view once it works, so `input` will be provided by dataview in the long run.
// let input = {sourceLink: dv.current().file.link}
function sourceLink(page) {
console.group(page.file.name)
let source = dv.array(page.source)
for (let s of source) {
console.group("Comparing " + typeof(s))
if (s == input.sourceLink.path) {
return true
}
console.groupEnd()
}
console.groupEnd()
}
console.group("find-citations")
console.log(input)
dv.table(
["Article","Summary"],
dv.pages("[[#]]").where(f => !f.file.path.startsWith("meta/")).sort((b) => b.file.inlinks.length, "desc").where(sourceLink).map( function(b) {
name = b.file.name;
if (b.file.aliases.length != 0) {
name = b.aliases[0]
}
return [dv.fileLink(b.file.path,false,name), b.summary]
})
)
console.groupEnd() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Your query looks fine at a first glance - are you having problems with it? |
Beta Was this translation helpful? Give feedback.
-
DVJS sample: dv.table(
["Article", "Summary"],
dv.current().file.inlinks
.map(t=>dv.page(t.path))
.where(t => t.source.path == dv.current().file.name)
.map(t=> [t.file.link, t.summary])
) DQL sample (doesn't work):
|
Beta Was this translation helpful? Give feedback.
DVJS sample:
DQL sample (doesn't work):