So, I was heavily inspired to make my own book list, that also accounts for books I have yet to read and books I am reading.
This is what it looks like, but the code is ‘messy’, if anyone has thoughts on cleaning it up it would be appreciated.
```dataviewjs
const {
update
} = this.app.plugins.plugins["metaedit"].api
const buttonMaker = (pn, pv, fpath, text) => {
const btn = this.container.createEl('button', {
"text": text,
"class": "button-55"
});
const file = this.app.vault.getAbstractFileByPath(fpath)
btn.addEventListener('click', async (evt) => {
evt.preventDefault();
await update(pn, pv, file);
});
return btn;
}
const {
createButton
} = app.plugins.plugins["buttons"]
for (let group of dv.pages("#book").where(p => p["time-read"] == null && moment(luxon.DateTime.now().toISODate()).diff(moment(p["release-date"])) < 0).groupBy(p => p.Started == null ? "Not Started" : "Currently Reading")) {
dv.header(4, group.key + ": " + group.rows.length);
dv.table(["Title", "Author", "Series", "Started On", " "],
group.rows.sort(k => k.Started, 'desc').map(k => ["[[" + k.file.path + "|" + k["Title"] + "]]", k["Author"], k["Series"] ? k["Series"] + ", " + k["number-in-series"] : "N/A", k["Started"] ? k["Started"] : "Untouched", k["Started"] && k["pageprogress"] / k["pagecount"] < 1 ? "<progress value=" + k["pageprogress"] / k["pagecount"] + " max=1></progress>" :
createButton({
app,
el: this.container,
args: {
name: k["Started"] ? "Completed" : "Begin"
},
clickOverride: {
click: update,
params: [k["Started"] ? "time-read" : "Started", luxon.DateTime.now().toISODate(), k.file.path]
}
})
]))
}
type or paste code here