%% generate tags start %%
#obsidian
%% generate tags end %%
#obsidian/plugin
Dataview only work in obsidian but not obsidian publish. To use it with obsidian publish, we need to generate markdown from it
## Templater
%% run start
```ts
const {LinkPreview} = customJS
return LinkPreview.getLinkPreviewFromUrl("https://joschua.io/posts/2023/09/01/obsidian-publish-dataview/")
```
%%
<div class="nifty-link-card-container">
<a class="nifty-link-card" href="https://joschua.io/posts/2023/09/01/obsidian-publish-dataview/" target="_blank">
<div class="nifty-link-card-text">
<div class="nifty-link-card-title line-clamp-2">Using Dataview on Obsidian Publish ยท joschua.io</div>
<div class="nifty-link-card-description">By default, you cannot use the Obsidian Dataview plugin on Obsidian Publish. But this blog post shows you how to use Dataview queries on you digital garden by using methods built into the Dataview API. We run through this by solving the problem of how to display recently edited files on Obsidian Publish.</div>
<div class="nifty-link-href">
<img class="nifty-link-icon" src="https://joschua.io/favicon.svg">
https://joschua.io/posts/2023/09/01/obsidian-publish-dataview/
</div>
</div>
<div class="nifty-link-image-container">
<div class="nifty-link-image" style="background-image: url('https://joschua.io/_astro/publish-hero-screenshot.d78b979a.png')">
</div>
</div>
</a>
</div>
%% run end %%
The old way will be using templater. But templater will replace your code in the document. unless you save it as a template, you cannot reuse (rerun) the code. Therefore you will create many templates.
## Run
%% run start
```ts
const {LinkPreview} = customJS
return LinkPreview.getLinkPreviewFromUrl("https://github.com/HananoshikaYomaru/obsidian-run")
```
%%
<div class="nifty-link-card-container">
<a class="nifty-link-card" href="https://github.com/HananoshikaYomaru/obsidian-run" target="_blank">
<div class="nifty-link-card-text">
<div class="nifty-link-card-title line-clamp-2">GitHub - HananoshikaYomaru/obsidian-run: Generate markdown from dataview query and javascript.</div>
<div class="nifty-link-card-description">Generate markdown from dataview query and javascript. - GitHub - HananoshikaYomaru/obsidian-run: Generate markdown from dataview query and javascript.</div>
<div class="nifty-link-href">
<img class="nifty-link-icon" src="https://github.com/fluidicon.png">
https://github.com/HananoshikaYomaru/obsidian-run
</div>
</div>
<div class="nifty-link-image-container">
<div class="nifty-link-image" style="background-image: url('https://opengraph.githubassets.com/5323d39f6c9d031e137a5f10bd3a391e78da6e326b504798fbb8a3d654f4b401/HananoshikaYomaru/obsidian-run')">
</div>
</div>
</a>
</div>
%% run end %%
A plugin that I created to generate markdown from javascript. This way is much easier because it require zero setup.
### Run Dataview
```ts
const query = `
TABLE dateformat(file.mtime, "dd.MM.yyyy - HH:mm") AS "Last modified"
FROM !"node_modules"
SORT file.mtime DESC LIMIT 100`
return dv.tryQueryMarkdown(query)
```
this script will create a Dataview table. To learn more: [Codeblock Reference - Dataview (blacksmithgu.github.io)](https://blacksmithgu.github.io/obsidian-dataview/api/code-reference/#dvtryquerymarkdownsource-file-settings)