Skip to content

Output markdown from your Dataview queries and keep them up to date. You can also be able to publish them.

License

Notifications You must be signed in to change notification settings

udus122/dataview-publisher

Repository files navigation

Davaview Publisher

Overview

Output markdown from your Dataview queries and keep them up to date. You can also be able to publish them.

Screenshots

screenshot

Prerequisites

This plugin uses the following two plugins, so you must install them:

Installation

Installing the plugin using BRAT

  1. Install the BRAT plugin
    1. Open Settings -> Community Plugins
    2. Disable safe mode, if enabled
    3. Browse, and search for "BRAT"
    4. Install the latest version of Obsidian 42 - BRAT
  2. Open BRAT settings (Settings -> Obsidian 42 - BRAT)
    1. Scroll to the Beta Plugin List section
    2. Add Beta Plugin
    3. Specify this repository: udus122/dataview-publisher
  3. Enable the Checkbox Time Tracker plugin (Settings -> Community Plugins)

Usage

%% DATAVIEW_PUBLISHER: start
```dataview
<Your favorite Dataview query>
```
%%
<Query results will be output as markdown here>
%% DATAVIEW_PUBLISHER: end %%

Tips: To suppress the original rendering, omit "dataview" of info string.

Examples

Dataview Query Language (DQL) query

Display a list of files tagged with #articles There are two notes tagged with #articles in the Vault (Article1.md, Article2.md).

%% DATAVIEW_PUBLISHER: start
```dataview
LIST FROM #articles SORT file.name
```
%%
- [[Article1.md|Article1]]
- [[Article2.md|Article2]]
%% DATAVIEW_PUBLISHER: end %%

For detailed instructions on how to write DQL, please refer to the Dataview documentation.

Dataview JS (Experimental)

Dataview can also output the results of executing arbitrary JavaScript code by setting the code block language (info string) to javascript, js, or dataviewjs.

This allows you to output Markdown strings in the desired format by using Dataview's Markdown functions.

%% DATAVIEW_PUBLISHER: start
```dataviewjs
const articles = dv.pages("#articles").map(article => `[[${article.file.name}]]`);
`
## Articles

${dv.markdownList(articles)}
`;
```
%%
## Articles

- [[Article1]]
- [[Article2]]
%% DATAVIEW_PUBLISHER: end %%

Dataview JS is executed using the eval() function. the last expression or value evaluated is output (Leading and trailing whitespace and newlines will be trimmed).

It doesn't render HTML, so it won't be output even if you use the Dataview's Render functions. Please output a Markdown string as the last expression or value.

Warning: It can be dangerous to execute arbitrary codes from untrusted sources. Only run codes that you understand, from trusted sources.

Settings

settings_screenshot

  • Source: Dataview source to search for the target file
    • This setting is used to narrow down the files to be updated, and is recommended for performance reasons
    • If left empty, this plugin will attempt to update all files in the Vault
  • Update on save: Automatically update output when file is saved
    • Only the Saved file is updated.

Commands

commands_screenshot

  • Insert dataview publish block
    • Insert Dataview Publisher Template at next line of cursor
  • Update dataview publish blocks
    • Update all Dataview Publish blocks for the files that correspond to the specified Source in settings.
  • Update dataview publish blocks and open publish panel
    • Same as "Update dataview publish blocks" and open publish panel.

Inspirations

This plugin highly inspirated by this article.

Using Dataview on Obsidian Publish

About

Output markdown from your Dataview queries and keep them up to date. You can also be able to publish them.

Resources

License

Stars

Watchers

Forks

Packages

No packages published