<%* const dv = app.plugins.plugins["dataview"].api; const openPublishPanel = app.commands.commands["publish:view-changes"].callback; // Add as many filenames and queries as you'd like! const fileAndQuery = new Map([ [ "Recently edited", 'TABLE dateformat(file.mtime, "ff") AS Modified FROM "Hobbies" OR "Professional Development" OR "Technical Mind Map" AND -#ignore SORT file.mtime DESC LIMIT 10', ], ["Recently Posted Blogs", 'TABLE dateformat(file.mtime, "ff") AS Modified, file.tags AS Tags FROM #blog-post AND -#ignore SORT file.mtime DESC LIMIT 10', ], ]); 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 = `%% #ignore update via "Update Publish Files" template %% \n\n${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(); %>