Color mode

Dataview

Evaluate declarative dataview code blocks against the content manifest at build time and render them as lists, tables, task lists, or calendars. No client-side JavaScript is required.

日本語

Overview

dataviewPlugin() recognises fenced blocks whose language is dataview:

md
```dataview
TABLE file.name AS "Name", status
FROM #project
WHERE status = "active"
SORT file.name asc
LIMIT 10
```

and renders them from the manifest using each public note's frontmatter, tags, links, and permalink. Unlisted, draft, and scheduled notes are excluded from queries. DataviewJS (dataviewjs) is not supported: those blocks stay code blocks and produce a diagnostic.

Usage

ts
import { defineConfig } from "@riebeckite/core";
import { dataviewPlugin } from "@riebeckite/plugin-dataview";
 
export default defineConfig({
  // ...
  plugins: [dataviewPlugin()],
});

Query syntax

A block starts with a query type (LIST, TABLE, TASK, or CALENDAR) followed by optional clauses:

text
LIST|TABLE|TASK|CALENDAR [expression or columns]
FROM <source expression>
WHERE <boolean expression>
SORT <field> [asc|desc][, ...]
GROUP BY <field>
LIMIT <n>

Clauses are case-insensitive. Each clause starts on its own line, but a clause body may span multiple lines.

LIST

LIST renders an unordered list of matching notes. An optional trailing expression is shown as metadata next to the link:

Dataview query
LIST file.date
FROM #diary
SORT file.date desc

TABLE

TABLE renders a table. When no columns are given, a single file.link column is used. Columns are field paths, optionally renamed with AS:

Namestatuspriority
dataview.en
dataview
showcase.en
showcase
Dataview query
TABLE file.name AS "Name", status, priority
FROM #project

TASK

TASK extracts the task list items (- [ ] / - [x]) from every matching note and renders them as <ul class="rb-dataview__tasks">. FROM and WHERE select the pages, not individual tasks:

No matching content.

Dataview query
TASK
FROM #project

CALENDAR

CALENDAR renders a month grid. The optional trailing expression selects the date field (default date). The month of the most recent matched date is shown:

No matching content.

Dataview query
CALENDAR date
FROM #project

Clauses

FROM

FROM selects candidate notes. Sources are:

Source Meaning
#tag Has the tag
"folder" Slug is the folder or lives under it
[[note]] Links to note (incoming links)

Combine sources with and / or, negate with ! or -, and group with parentheses. Adjacent sources are treated as and.

Dataview block in `docs/plugins/dataview.en` unsupported query type `FROM`; expected LIST, TABLE, TASK, or CALENDAR.

Dataview query
FROM (#project or #area) and "notes" and !#archive

WHERE

WHERE filters notes with a boolean expression over file.* and frontmatter fields.

Feature Examples
Comparison status = "active", priority > 2, date <= "2026-12-31"
Boolean status = "active" and !draft, a or b
contains() contains(file.tags, "#project"), contains(tags, "project")
date() date(due) >= date("2026-01-01")
number() / string() number(weight) > 3

String =/!= comparisons and contains() are case-insensitive. date() returns a millisecond timestamp (or null), so date(a) < date(b) compares chronologically. null/missing values never satisfy </> comparisons.

file.* fields: file.name, file.title, file.slug, file.path, file.folder, file.link, file.permalink, file.url, file.tags, file.date, file.created, file.updated, file.published. Other frontmatter keys are read directly by name (status, priority, due, ...).

SORT

SORT accepts a comma-separated list of fields with an optional direction (asc, the default, or desc). Notes with a missing field sort last.

Dataview block in `docs/plugins/dataview.en` unsupported query type `SORT`; expected LIST, TABLE, TASK, or CALENDAR.

Dataview query
SORT priority desc, file.name asc

GROUP BY

GROUP BY <field> groups the matched notes. Each group is headed by the group value; LIST and TASK render one list per group, and TABLE inserts a group row. Groups keep the order established by SORT.

LIMIT

LIMIT <n> caps the number of rendered notes (before grouping). It can also be set for every block with the limit option.

Options

Option Type Default Description
className string "rb-dataview" Root CSS class
language string "dataview" Fence language to target
hideFallback boolean false Hide the raw-query <details> fallback
limit number none Default LIMIT when a block omits one

Rendering

Each block becomes:

html
<div class="rb-dataview" data-dataview data-dataview-type="list">
  <!-- list, table, task, or calendar output -->
  <details class="rb-dataview__fallback">
    <summary>Dataview query</summary>
    <pre><code>LIST FROM #project</code></pre>
  </details>
</div>

The readable <details> fallback contains the raw query and can be disabled with hideFallback.

Diagnostics

  • dataviewjs blocks are left untouched and emit a dataview-unsupported-language warning. The markdown-time remark transform also records a file.message with source: "@riebeckite/plugin-dataview".
  • Blocks the parser or evaluator cannot handle render an inline error box and emit a dataview-invalid error diagnostic. Unsupported syntax is also reported through file.message while the markdown is parsed.

Limitations

  • No DataviewJS. dataviewjs is intentionally unsupported.
  • No inline fields (field:: value). Only frontmatter is read.
  • TABLE columns are field paths, not arbitrary expressions. Rename with AS "Label"; computed columns (for example file.size / 1024) are not supported.
  • TASK filters pages, not tasks. WHERE/FROM apply to the notes that contain tasks.
  • CALENDAR shows one month — the month of the most recent matched date.
  • file.size, file.mtime, and file.ctime are not available from the manifest and evaluate to undefined.
  • Results are fixed at build time and links produced by a dataview block are not added to the content graph (backlinks). A full build always recomputes correctly.

Exports

  • dataviewPlugin(options?) / dataview(options?) — plugin factory
  • remarkDataview(options?) — remark transform usable on its own
  • parseDataview(source) — parse a block body into a DataviewSpec
  • selectDataviewEntries(spec, manifest, defaultLimit) — matching engine
  • evaluateDataviewExpression(expression, scope) and matchesDataviewFrom(from, entry, manifest) — expression helpers
  • renderDataview(selection, spec, options, source) — HTML renderer
  • resolveDataviewOptions(options?) — normalise plugin options
  • DATAVIEW_ATTRIBUTE — placeholder attribute name
  • Types: DataviewOptions, DataviewSpec, DataviewQueryType, DataviewExpression, DataviewFrom, and friends

See also

History

1 changesCollapseExpand
1 + <!-- Generated from packages/plugins/dataview/README.md. Do not edit this page directly; edit the package README and run `pnpm docs:sync`. -->
2 +
3 + # Dataview
4 +
5 + Evaluate declarative `dataview` code blocks against the content manifest at
6 + build time and render them as lists, tables, task lists, or calendars. No
7 + client-side JavaScript is required.
8 +
9 + [日本語](./dataview.md)
10 +
11 + ## Overview
12 +
13 + `dataviewPlugin()` recognises fenced blocks whose language is `dataview`:
14 +
15 + ````md
16 + ```dataview
17 + TABLE file.name AS "Name", status
18 + FROM #project
19 + WHERE status = "active"
20 + SORT file.name asc
21 + LIMIT 10
22 + ```
23 + ````
24 +
25 + and renders them from the manifest using each public note's frontmatter, tags,
26 + links, and permalink. Unlisted, draft, and scheduled notes are excluded from
27 + queries. DataviewJS (`dataviewjs`) is **not** supported: those blocks stay
28 + code blocks and produce a diagnostic.
29 +
30 + ## Usage
31 +
32 + ```ts
33 + import { defineConfig } from "@riebeckite/core";
34 + import { dataviewPlugin } from "@riebeckite/plugin-dataview";
35 +
36 + export default defineConfig({
37 + // ...
38 + plugins: [dataviewPlugin()],
39 + });
40 + ```
41 +
42 + ## Query syntax
43 +
44 + A block starts with a query type (`LIST`, `TABLE`, `TASK`, or `CALENDAR`)
45 + followed by optional clauses:
46 +
47 + ```
48 + LIST|TABLE|TASK|CALENDAR [expression or columns]
49 + FROM <source expression>
50 + WHERE <boolean expression>
51 + SORT <field> [asc|desc][, ...]
52 + GROUP BY <field>
53 + LIMIT <n>
54 + ```
55 +
56 + Clauses are case-insensitive. Each clause starts on its own line, but a clause
57 + body may span multiple lines.
58 +
59 + ### `LIST`
60 +
61 + `LIST` renders an unordered list of matching notes. An optional trailing
62 + expression is shown as metadata next to the link:
63 +
64 + ```dataview
65 + LIST file.date
66 + FROM #diary
67 + SORT file.date desc
68 + ```
69 +
70 + ### `TABLE`
71 +
72 + `TABLE` renders a table. When no columns are given, a single `file.link` column
73 + is used. Columns are field paths, optionally renamed with `AS`:
74 +
75 + ```dataview
76 + TABLE file.name AS "Name", status, priority
77 + FROM #project
78 + ```
79 +
80 + ### `TASK`
81 +
82 + `TASK` extracts the task list items (`- [ ]` / `- [x]`) from every matching
83 + note and renders them as `<ul class="rb-dataview__tasks">`. `FROM` and `WHERE`
84 + select the **pages**, not individual tasks:
85 +
86 + ```dataview
87 + TASK
88 + FROM #project
89 + ```
90 +
91 + ### `CALENDAR`
92 +
93 + `CALENDAR` renders a month grid. The optional trailing expression selects the
94 + date field (default `date`). The month of the most recent matched date is shown:
95 +
96 + ```dataview
97 + CALENDAR date
98 + FROM #project
99 + ```
100 +
101 + ## Clauses
102 +
103 + ### `FROM`
104 +
105 + `FROM` selects candidate notes. Sources are:
106 +
107 + | Source | Meaning |
108 + | ------ | ------- |
109 + | `#tag` | Has the tag |
110 + | `"folder"` | Slug is the folder or lives under it |
111 + | `[[note]]` | Links to `note` (incoming links) |
112 +
113 + Combine sources with `and` / `or`, negate with `!` or `-`, and group with
114 + parentheses. Adjacent sources are treated as `and`.
115 +
116 + ```dataview
117 + FROM (#project or #area) and "notes" and !#archive
118 + ```
119 +
120 + ### `WHERE`
121 +
122 + `WHERE` filters notes with a boolean expression over `file.*` and frontmatter
123 + fields.
124 +
125 + | Feature | Examples |
126 + | ------- | -------- |
127 + | Comparison | `status = "active"`, `priority > 2`, `date <= "2026-12-31"` |
128 + | Boolean | `status = "active" and !draft`, `a or b` |
129 + | `contains()` | `contains(file.tags, "#project")`, `contains(tags, "project")` |
130 + | `date()` | `date(due) >= date("2026-01-01")` |
131 + | `number()` / `string()` | `number(weight) > 3` |
132 +
133 + String `=`/`!=` comparisons and `contains()` are case-insensitive. `date()`
134 + returns a millisecond timestamp (or `null`), so `date(a) < date(b)` compares
135 + chronologically. `null`/missing values never satisfy `<`/`>` comparisons.
136 +
137 + `file.*` fields: `file.name`, `file.title`, `file.slug`, `file.path`,
138 + `file.folder`, `file.link`, `file.permalink`, `file.url`, `file.tags`,
139 + `file.date`, `file.created`, `file.updated`, `file.published`. Other frontmatter
140 + keys are read directly by name (`status`, `priority`, `due`, ...).
141 +
142 + ### `SORT`
143 +
144 + `SORT` accepts a comma-separated list of fields with an optional direction
145 + (`asc`, the default, or `desc`). Notes with a missing field sort last.
146 +
147 + ```dataview
148 + SORT priority desc, file.name asc
149 + ```
150 +
151 + ### `GROUP BY`
152 +
153 + `GROUP BY <field>` groups the matched notes. Each group is headed by the group
154 + value; `LIST` and `TASK` render one list per group, and `TABLE` inserts a group
155 + row. Groups keep the order established by `SORT`.
156 +
157 + ### `LIMIT`
158 +
159 + `LIMIT <n>` caps the number of rendered notes (before grouping). It can also be
160 + set for every block with the `limit` option.
161 +
162 + ## Options
163 +
164 + | Option | Type | Default | Description |
165 + | ------ | ---- | ------- | ----------- |
166 + | `className` | `string` | `"rb-dataview"` | Root CSS class |
167 + | `language` | `string` | `"dataview"` | Fence language to target |
168 + | `hideFallback` | `boolean` | `false` | Hide the raw-query `<details>` fallback |
169 + | `limit` | `number` | none | Default `LIMIT` when a block omits one |
170 +
171 + ## Rendering
172 +
173 + Each block becomes:
174 +
175 + ```html
176 + <div class="rb-dataview" data-dataview data-dataview-type="list">
177 + <!-- list, table, task, or calendar output -->
178 + <details class="rb-dataview__fallback">
179 + <summary>Dataview query</summary>
180 + <pre><code>LIST FROM #project</code></pre>
181 + </details>
182 + </div>
183 + ```
184 +
185 + The readable `<details>` fallback contains the raw query and can be disabled
186 + with `hideFallback`.
187 +
188 + ## Diagnostics
189 +
190 + - `dataviewjs` blocks are left untouched and emit a
191 + `dataview-unsupported-language` **warning**. The markdown-time remark
192 + transform also records a `file.message` with
193 + `source: "@riebeckite/plugin-dataview"`.
194 + - Blocks the parser or evaluator cannot handle render an inline error box and
195 + emit a `dataview-invalid` **error** diagnostic. Unsupported syntax is also
196 + reported through `file.message` while the markdown is parsed.
197 +
198 + ## Limitations
199 +
200 + - **No DataviewJS.** `dataviewjs` is intentionally unsupported.
201 + - **No inline fields** (`field:: value`). Only frontmatter is read.
202 + - **`TABLE` columns are field paths**, not arbitrary expressions. Rename with
203 + `AS "Label"`; computed columns (for example `file.size / 1024`) are not
204 + supported.
205 + - **`TASK` filters pages, not tasks.** `WHERE`/`FROM` apply to the notes that
206 + contain tasks.
207 + - **`CALENDAR` shows one month** — the month of the most recent matched date.
208 + - `file.size`, `file.mtime`, and `file.ctime` are not available from the
209 + manifest and evaluate to `undefined`.
210 + - Results are fixed at build time and links produced by a dataview block are not
211 + added to the content graph (backlinks). A full build always recomputes
212 + correctly.
213 +
214 + ## Exports
215 +
216 + - `dataviewPlugin(options?)` / `dataview(options?)` — plugin factory
217 + - `remarkDataview(options?)` — remark transform usable on its own
218 + - `parseDataview(source)` — parse a block body into a `DataviewSpec`
219 + - `selectDataviewEntries(spec, manifest, defaultLimit)` — matching engine
220 + - `evaluateDataviewExpression(expression, scope)` and
221 + `matchesDataviewFrom(from, entry, manifest)` — expression helpers
222 + - `renderDataview(selection, spec, options, source)` — HTML renderer
223 + - `resolveDataviewOptions(options?)` — normalise plugin options
224 + - `DATAVIEW_ATTRIBUTE` — placeholder attribute name
225 + - Types: `DataviewOptions`, `DataviewSpec`, `DataviewQueryType`,
226 + `DataviewExpression`, `DataviewFrom`, and friends
227 +
228 + ## See also
229 +
230 + - [Plugin guide](../reference/plugin-api.en.md)
231 +