Hi all, hoping you can help me get over the finish line.
What I’m trying to do
I’m trying to write a query that sorts the files in #project by most recently edited, but I want that to include the mtime of any page that has that project as a parent. So I want projects ordered by what I most recently worked on, including subpages.
I’m mostly there—the problem is that I don’t know how to match with values that are also links.
So for frontmatter that looks like this:
And for the body, that looks like this:
And for the body, that looks like this:
Things I have tried
let update = dv.pages()
.where(p =>
p.parent === project.file.name ||
p.file.name === project.file.name ||
dv.array(p.parent)[0] === project.file.name)
Any ideas? Full codeblock below.
let projects = dv.pages("#project and -#project/todos and -#archival")
.where(p => !p.file.folder.includes("Dailies") & !p.file.folder.includes("Inbox"));
let stack = [];
for (let project of projects) {
let update = dv.pages()
.where(p =>
p.parent === project.file.name ||
p.file.name === project.file.name || dv.array(p.parent)[0] === project.file.name)
.sort(p => p.file.mtime, 'desc')[0]
.file.mtime;
let pair = [project.file.link, update];
stack.push(pair); // so now I've added the file and the corresponding mtime to the stack.
} // leaving this loop, stack is a 2D array of ordered pairs. Each pair has a file link, and an mtime that corresponds to a subproject. Now I want to sort by that mtime.
dv.table(["Project","Modified"],
dv.array(stack)
.sort(p => p[1], 'desc').slice(0,10)
);