```
<%*
// Stolen from https://joschua.io/posts/2023/09/01/obsidian-publish-dataview/
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 created notes",
'TABLE WITHOUT ID file.link AS Note, dateformat(file.ctime, "[[1yyyy-MM-dd]]") AS "Created", dateformat(file.mtime, "[[1yyyy-MM-dd]]") AS "Updated" SORT file.ctime DESC LIMIT 10',
],
[
"Recently updated notes",
'TABLE WITHOUT ID file.link AS Note, dateformat(file.ctime, "[[1yyyy-MM-dd]]") AS "Created", dateformat(file.mtime, "[[1yyyy-MM-dd]]") AS "Updated" 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 = `---\npublish: true\nignore: true\ntags: \n - meta\n - MOC\n---\n%% update: Cmd+Shift+P %% \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();
%>
```