<%* 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([ // Update Publish Files.md [ "Recently edited", 'TABLE WITHOUT ID file.link AS Note, dateformat(file.mtime, "ff") AS Modified FROM "Books of Knowledge" OR "Insights" WHERE modified SORT file.mtime desc LIMIT 7', ], [ "Recent new files", 'TABLE WITHOUT ID file.link AS Note, dateformat(file.ctime, "DD") AS Added FROM "Books of Knowledge" OR "Insights" WHERE created SORT file.ctime desc LIMIT 7', ], [ "PKM books", 'TABLE WITHOUT ID file.link AS Title, ("![|150](" + cover + ")") as Cover, author as Author FROM "Sources/books" WHERE contains(relates-to, [[Personal Knowledge Management]]) SORT file.name ASC', ], [ "IA books", 'TABLE WITHOUT ID file.link AS Title, ("![|150](" + cover + ")") as Cover, author AS Author FROM "Sources/books" WHERE contains(relates-to, [[information architecture]]) AND !contains(relates-to, [[search]]) SORT file.name ASC', ], [ "Navigation and Search books", 'TABLE WITHOUT ID file.link AS Title, ("![|150](" + cover + ")") as Cover, author AS Author FROM "Sources/books" WHERE contains(relates-to, [[search]]) OR contains(relates-to, [[navigation]]) SORT file.name ASC', ], [ "Information Behavior books", 'TABLE WITHOUT ID file.link AS Title, ("![|150](" + cover + ")") as Cover, author AS Author FROM "Sources/books" WHERE contains(relates-to, [[information behavior]]) SORT file.name ASC', ], [ "Taxonomy, Ontology, Organizing Information books", 'TABLE WITHOUT ID file.link AS Title, ("![|150](" + cover + ")") as Cover, author AS Author FROM "Sources/books" WHERE contains(relates-to, [[taxonomy]]) OR contains(relates-to, [[ontology]]) OR contains(relates-to, [[information organization]]) 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 = `---\npublish: true\n---\n%% 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(); %>