<%* const dv = app.plugins.plugins["dataview"].api; const openPublishPanel = app.commands.commands["publish:view-changes"].callback; const fileAndQuery = new Map([ // Meta [ "Index of blog entries by date", 'LIST WITHOUT ID "<code>" + dateformat(date,"yyyy-MM-dd") + "</code> " + file.link FROM -"includes" WHERE publish = true AND type = "blog" SORT date DESC' ], [ "Index of notes", 'LIST WITHOUT ID file.name FROM -"includes" WHERE publish = true AND type = "note" SORT file.name ASC' ], [ "Index of notes by tag", 'LIST rows.file.link FROM -"includes" WHERE publish = true AND type = "note" SORT file.name ASC FLATTEN file.etags AS tags GROUP BY tags' ], [ "Index of random notes", 'LIST WITHOUT ID file.link FROM -"includes" WHERE publish = true AND type = "note" FLATTEN date(now) as Now FLATTEN (file.mtime.year + file.mtime.hour + file.mtime.day + file.mtime.hour + file.mtime.minute + file.mtime.second + file.size + Now.hour + Now.minute + Now.second) * 15485863 as Hash FLATTEN ((Hash * Hash * Hash) % 2038074743) / 2038074743 as Rand WHERE max(Rand) SORT Rand LIMIT 5' ], [ "Index of recent notes", 'LIST WITHOUT ID join(list(file.link, dateformat(file.mtime,"yyyy-MM-dd")), " (") + ")" FROM -"includes" WHERE publish = true AND type = "note" SORT file.mtime DESC LIMIT 5' ], [ "Index of recent thematic indices", 'LIST WITHOUT ID join(list(file.link, dateformat(file.mtime,"yyyy-MM-dd")), " (") + ")" FROM -"includes" WHERE publish = true AND type = "index/thematic" SORT file.mtime DESC LIMIT 3' ], [ "Index of tags", 'TABLE length(rows.file.name) AS Notes FROM -"includes" WHERE type = "note" FLATTEN file.etags AS Tags GROUP BY Tags' ], // Reference [ "Index of references", 'LIST rows.file.link FROM -"includes" WHERE publish = true AND regexmatch("^reference(?:/|$)", lower(type)) SORT file.name ASC GROUP BY lower(type)' ], //Thematic [ "Index of cognitive biases", 'LIST WITHOUT ID file.link FROM -"includes" AND #SocialSciences/Psychology/Cognitive/Bias WHERE publish = true AND type = "note" SORT file.name ASC' ], [ "Index of parables", 'LIST WITHOUT ID file.link FROM -"includes" AND #Index/Parable WHERE publish = true AND type = "note" SORT file.name ASC' ] ]); await fileAndQuery.forEach(async (query, filename) => { if (!tp.file.find_tfile(filename)) { await tp.file.create_new("", filename); new Notice(`Created ${filename}.`); } const tFile = tp.file.find_tfile(filename); const queryOutput = await dv.queryMarkdown(query); const fileContent = `${queryOutput.value}`; try { await app.vault.modify(tFile, fileContent); new Notice(`Updated ${tFile.basename}.`); } catch (error) { new Notice("⚠️ ERROR updating! Check console. Skipped file: " + filename , 0); } }); openPublishPanel(); %>