function listChildren(children, offset = " ") {
let result = "\n"
for (const child of children) {
result += offset + "- " +
(child.task ? `[${ child.status ?? " "}] ` : "" ) +
child.text + "\n"
if (child.children.length) {
result += listChildren(child.children, offset + " ")
}
}
return result
}
let pages = dv.pages('"Journal"').filter(p => p.date)
let months = pages.groupBy(p => DateTime.fromISO(p.date).toFormat("%%yyyy-MM%%MMMM yyyy"))
for (let month of months) {
let lists = pages.where(p => p.date && DateTime.fromISO(p.date).toFormat("%%yyyy-MM%%MMMM yyyy") == month.key).file.lists;
let keyIdeas = lists.filter(l => l.tags && dv.func.contains(l.tags, "#pin"))
if(keyIdeas.length > 0) { dv.header(4, `${ month.key }`); }
dv.paragraph(dv.markdownList(
keyIdeas.map(l => l.text + listChildren(l.children))
))
}
For in case anyone has a weirdly-specific DataviewJS query and needs an example.
Related Forum Posts: