How to upload dataview result to obsidian publish?

How to upload dataview result to obsidian publish?

Way to upload dataview query result to obsidian publish.

Problem Description

  • In Obsidian, you can write documents through many community plugins.

  • However, the result of this document writing is not properly applied to Obsidian Publish.

  • Let's try uploading the Dataview plugin, which is most commonly used in document writing, to Obsidian Publish.

Why is This Problem Occurring?

  • Obsidian is just a bunch of Markdown.

  • All sorts of plugins add Javascript to the Markdown bunches.

  • Obsidian Publish is a feature for uploading bunches, but it does not upload Javascript along with them.

Solutions

  1. Upload the Dataview plugin to Obsidian Publish

    • Disadvantages

      • Every time the Dataview plugin is updated, you have to update it manually.

      • All files needed for Dataview must be uploaded to Obsidian Publish.

  2. Convert Dataview results to Markdown and then upload to Obsidian Publish.

The disadvantages of option 1 are too clear, so I plan to use option 2.

Converting Dataview to Markdown

What happens if you upload the dataview query as is? Instead of uploading the results of the dataview query, the dataview query itself gets uploaded. The reason is, Obsidian Publish just uploads the bunches.

This issue has actually been a demand from many users for a long time, and the method is well-known.

First, let's assume you wrote a query like the following.

LIST
FROM #tag
SORT file.name ASC

If you want to post this query to Obsidian Publish, you need to change the query to a Markdown form using the queryMarkdown API.

const dv = app.plugins.plugins["dataview"].api;
const queryOutput = await dv.queryMarkdown("LIST FROM #tag SORT file.name ASC");
console.log(queryOutput);

If you check the result, you can see that the output of dataview has been converted to Markdown. You can copy this result and paste it into the desired Markdown to use it.

  • (Scheduled for upload on 231217) Automating a page on Obsidian Publish that gathers recently modified/registered posts (Example, my blog)