What I’m trying to do
Show all callout text using dataview and sort by date modified. Also, only one callout type is shown using the code below, and I would like for all callouts to be shown.
Things I have tried
I am using a gist I found to successfully to view callouts (and I left a comment on the gist asking the same question a few weeks ago, I’m now looking at this issue again). I’ve tried combining methods from a post regarding callouts (Trying to retrieve Callout with DataView) and posts regarding sorting lists (Sorting with Dataviewjs & Metadata Menu, Sorting Dataview JS) but something is missing, I’m not a js guy and none of these solutions are structured quite the same way so I haven’t been able to cobble together a solution for my case.
Here is the code, mostly unchanged from the snippet posted by another user:
const pages = dv.pages()
const regex = /\s*\>\s*\[\![^\]]+\]\n\s*>\s*(.*)\n/gm
const rows = []
for (const page of pages) {
// Read the file contents
const file = app.vault.getAbstractFileByPath(page.file.path)
const contents = await app.vault.read(file);
// Add all callouts to the rows
const callout = contents.match(regex) || [];
if (callout.length > 0) {
rows.push([page.file.link, callout.join('\n')])}
}
// Create table
dv.table(['Note', ''], rows)
Where would I place a sort function in this case? What is the correct syntax for sorting by date modified?
Perhaps a different question, but, why is this only showing one callout type with the regex the way it is?
Thank you!