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 ofMarkdown
.All sorts of plugins add
Javascript
to theMarkdown
bunches.Obsidian Publish
is a feature for uploading bunches, but it does not uploadJavascript
along with them.
Solutions
Upload the
Dataview
plugin toObsidian Publish
Disadvantages
Every time the
Dataview
plugin is updated, you have to update it manually.All files needed for
Dataview
must be uploaded toObsidian Publish
.
Convert
Dataview
results toMarkdown
and then upload toObsidian 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 thedataview
query, thedataview
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)