If I have a dv.pages() function like this, how can I modify it so it also filters to only pages that contain [ ] (incomplete tasks). I did some looking up but couldn’t find answers.
Someone showed me a code sample here to solve it, which I adapted:
let pages = dv.pages();
let rows = [];
for (let [index, p] of Object.entries(pages.values)) {
var has_tasks = false;
var content = await dv.io.load(p.file.path);
if (content.contains("behind")){
rows.push([p.file.link]);
}
}
dv.table(["File"],
rows.map(v => v) );
As stated in the documentation, where takes a function that returns a boolean value.
export interface DataArray<T> {
/** Filter the data array down to just elements which match the given predicate. */
where(predicate: (elem: T, index: number, arr: T[]) => boolean): DataArray<T>;
}
So this should work: dv.pages("(1) Misc Notes/tasks").where(p => p.Completed != true && p.Status != 'Waiting' && p["Task Size"] != 'Large')