@riebeckite/plugin-bases 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +180 -180
- package/README_ja.md +155 -155
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,180 +1,180 @@
|
|
|
1
|
-
# @riebeckite/plugin-bases
|
|
2
|
-
|
|
3
|
-
Render Obsidian Bases definitions from fenced `base` code blocks. Filtering,
|
|
4
|
-
sorting, and view composition run against the content manifest at build time, so
|
|
5
|
-
no client-side JavaScript is required.
|
|
6
|
-
|
|
7
|
-
[日本語](./README_ja.md)
|
|
8
|
-
|
|
9
|
-
## Overview
|
|
10
|
-
|
|
11
|
-
`bases()` recognises fenced blocks
|
|
12
|
-
|
|
13
|
-
````md
|
|
14
|
-
```base
|
|
15
|
-
filters:
|
|
16
|
-
and:
|
|
17
|
-
- file.hasTag("featured")
|
|
18
|
-
properties:
|
|
19
|
-
file.name:
|
|
20
|
-
displayName: Title
|
|
21
|
-
file.tags:
|
|
22
|
-
displayName: Tags
|
|
23
|
-
views:
|
|
24
|
-
- type: table
|
|
25
|
-
name: Featured
|
|
26
|
-
order:
|
|
27
|
-
- file.name
|
|
28
|
-
- file.tags
|
|
29
|
-
limit: 10
|
|
30
|
-
```
|
|
31
|
-
````
|
|
32
|
-
|
|
33
|
-
and renders them using the content manifest (every note's frontmatter, tags,
|
|
34
|
-
links, and permalink).
|
|
35
|
-
|
|
36
|
-
## Usage
|
|
37
|
-
|
|
38
|
-
```ts
|
|
39
|
-
import { defineConfig } from "@riebeckite/core";
|
|
40
|
-
import { bases } from "@riebeckite/plugin-bases";
|
|
41
|
-
|
|
42
|
-
export default defineConfig({
|
|
43
|
-
// ...
|
|
44
|
-
plugins: [bases()],
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Block syntax
|
|
49
|
-
|
|
50
|
-
The block body is an Obsidian Base YAML document.
|
|
51
|
-
|
|
52
|
-
| Field | Type | Description |
|
|
53
|
-
| ----- | ---- | ----------- |
|
|
54
|
-
| `filters` | expression \| list \| object | Top-level filter applied to every view (below) |
|
|
55
|
-
| `properties` | object | Property id -> display name (or `{ displayName }`) |
|
|
56
|
-
| `views` | object[] | One or more views |
|
|
57
|
-
|
|
58
|
-
### Views
|
|
59
|
-
|
|
60
|
-
| Field | Type | Description |
|
|
61
|
-
| ----- | ---- | ----------- |
|
|
62
|
-
| `type` | `"table"` \| `"cards"` | Output kind. Defaults to `table` |
|
|
63
|
-
| `name` | string | Optional label rendered above the view |
|
|
64
|
-
| `filters` | filter | Additional filter, combined with the top-level filter using AND |
|
|
65
|
-
| `order` | string \| string[] | Columns (property ids) and their display order |
|
|
66
|
-
| `columns` | string \| string[] | Alias for `order` |
|
|
67
|
-
| `sort` | object \| object[] \| string | Sort keys (below) |
|
|
68
|
-
| `limit` | number | Row cap for this view; still bounded by the `limit` option |
|
|
69
|
-
|
|
70
|
-
`sort` accepts the Core shape `{ field, order }`, the Obsidian shape
|
|
71
|
-
`{ property, direction }`, or a shorthand string (`"-file.name"` sorts
|
|
72
|
-
descending). When a view omits `order`/`columns`, the columns are the keys of
|
|
73
|
-
`properties` (in order), or `["file.name", "file.tags"]`.
|
|
74
|
-
|
|
75
|
-
### Filter grammar
|
|
76
|
-
|
|
77
|
-
A filter is an expression string, a list of expressions (treated as AND), or an
|
|
78
|
-
object with `and` / `or` / `not` keys. `and` and `or` take a list; `not` takes an
|
|
79
|
-
expression or a list (the list is ANDed, then negated). A plain object whose keys
|
|
80
|
-
are property names is treated as equality.
|
|
81
|
-
|
|
82
|
-
| Expression | Description |
|
|
83
|
-
| ---------- | ----------- |
|
|
84
|
-
| `file.hasTag("x")` | Has the tag `x` (or a subtag `x/...`). Case-insensitive |
|
|
85
|
-
| `file.inFolder("x")` | Slug equals `x` or starts with `x/` |
|
|
86
|
-
| `file.hasLink("x")` | Links to `x` (by resolved slug, raw target, or file name) |
|
|
87
|
-
| `file.name` / `file.title` | Note title |
|
|
88
|
-
| `file.path` / `file.slug` | Slug |
|
|
89
|
-
| `file.folder` | Parent folder of the slug |
|
|
90
|
-
| `file.link` / `file.permalink` | Permalink |
|
|
91
|
-
| `file.tags` | Tags |
|
|
92
|
-
| `note.key` / `key` | A frontmatter value |
|
|
93
|
-
|
|
94
|
-
Comparisons use `==`, `!=`, `>`, `<`, `>=`, `<=`, and `contains`. String
|
|
95
|
-
comparisons are case-insensitive; `contains` tests array membership or substring
|
|
96
|
-
containment. Bare scalar lists are ANDed.
|
|
97
|
-
|
|
98
|
-
```yaml
|
|
99
|
-
filters:
|
|
100
|
-
and:
|
|
101
|
-
- file.hasTag("featured")
|
|
102
|
-
- or:
|
|
103
|
-
- note.status == "published"
|
|
104
|
-
- note.status == "review"
|
|
105
|
-
- not:
|
|
106
|
-
- file.hasTag("draft")
|
|
107
|
-
views:
|
|
108
|
-
- type: table
|
|
109
|
-
name: Featured
|
|
110
|
-
order: [file.name, note.status]
|
|
111
|
-
sort:
|
|
112
|
-
- property: file.name
|
|
113
|
-
direction: ASC
|
|
114
|
-
limit: 20
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Options
|
|
118
|
-
|
|
119
|
-
| Option | Type | Default | Description |
|
|
120
|
-
| ------ | ---- | ------- | ----------- |
|
|
121
|
-
| `className` | `string` | `"rb-bases"` | Root CSS class |
|
|
122
|
-
| `language` | `string` | `"base"` | Fence language to target |
|
|
123
|
-
| `limit` | `number` | `100` | Global row cap applied to every view |
|
|
124
|
-
| `showFallback` | `boolean` | `true` | Render the raw Base definition in a `<details>` fallback |
|
|
125
|
-
| `view` | `string` | none | Render only the view with this name when a Base defines several |
|
|
126
|
-
|
|
127
|
-
## Output HTML / CSS hooks
|
|
128
|
-
|
|
129
|
-
```html
|
|
130
|
-
<div class="rb-bases" data-bases data-bases-view="table">
|
|
131
|
-
<section class="rb-bases__view" data-bases-view="table">
|
|
132
|
-
<h3 class="rb-bases__view-name">Featured</h3>
|
|
133
|
-
<table class="rb-bases__table"> ... </table>
|
|
134
|
-
</section>
|
|
135
|
-
<details class="rb-bases__fallback"> ... </details>
|
|
136
|
-
</div>
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Stable classes: `rb-bases`, `rb-bases__view`, `rb-bases__view-name`,
|
|
140
|
-
`rb-bases__table`, `rb-bases__heading`, `rb-bases__cell`, `rb-bases__row`,
|
|
141
|
-
`rb-bases__link`, `rb-bases__tags`, `rb-bases__tag`, `rb-bases__cards`,
|
|
142
|
-
`rb-bases__card`, `rb-bases__card-title`, `rb-bases__fields`, `rb-bases__field`,
|
|
143
|
-
`rb-bases__field-label`, `rb-bases__field-value`, `rb-bases__empty`,
|
|
144
|
-
`rb-bases__fallback`, `rb-bases--error`. Stable attributes: `data-bases`,
|
|
145
|
-
`data-bases-view`.
|
|
146
|
-
|
|
147
|
-
## Diagnostics
|
|
148
|
-
|
|
149
|
-
A block that is not valid YAML, or that uses an unsupported filter expression or
|
|
150
|
-
view shape, is left as a code block and reported through `file.message(...)` with
|
|
151
|
-
`source: "@riebeckite/plugin-bases"`.
|
|
152
|
-
|
|
153
|
-
## Limitations
|
|
154
|
-
|
|
155
|
-
This is an MVP subset of Obsidian Bases:
|
|
156
|
-
|
|
157
|
-
- Only the `table` and `cards` view types are rendered.
|
|
158
|
-
- Inline boolean operators (`&&`, `||`, `!`) are not supported; use the
|
|
159
|
-
`and` / `or` / `not` YAML structure.
|
|
160
|
-
- `if()` / `filter()` and other Base formula functions are not supported.
|
|
161
|
-
- Nested property paths and `file.mtime` / `file.ctime` are mapped onto `date`.
|
|
162
|
-
- Property-to-property comparisons are not supported; the right-hand side is a
|
|
163
|
-
literal.
|
|
164
|
-
- Results are fixed at build time. Rebuilding a host note when a queried note
|
|
165
|
-
changes is future work; a full build always recomputes correctly.
|
|
166
|
-
|
|
167
|
-
## Exports
|
|
168
|
-
|
|
169
|
-
- `bases(options?)` — plugin factory (alias: `basesPlugin`)
|
|
170
|
-
- `remarkBases(options?)` — remark transform usable on its own (`options.language`
|
|
171
|
-
selects the fence language)
|
|
172
|
-
- `parseBases(document)` — compiles a parsed YAML Base document to a spec
|
|
173
|
-
- `matchesCondition(condition, entry)` — condition evaluator
|
|
174
|
-
- Types: `BasesOptions`, `BasesSpec`, `BasesView`, `BasesViewType`,
|
|
175
|
-
`BasesCondition`, `BasesValueRef`, `BasesBuiltinValue`, `BasesOperator`,
|
|
176
|
-
`BasesLiteral`
|
|
177
|
-
|
|
178
|
-
## See also
|
|
179
|
-
|
|
180
|
-
- [Plugin guide](../../../docs/en/plugin-
|
|
1
|
+
# @riebeckite/plugin-bases
|
|
2
|
+
|
|
3
|
+
Render Obsidian Bases definitions from fenced `base` code blocks. Filtering,
|
|
4
|
+
sorting, and view composition run against the content manifest at build time, so
|
|
5
|
+
no client-side JavaScript is required.
|
|
6
|
+
|
|
7
|
+
[日本語](./README_ja.md)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
`bases()` recognises fenced blocks
|
|
12
|
+
|
|
13
|
+
````md
|
|
14
|
+
```base
|
|
15
|
+
filters:
|
|
16
|
+
and:
|
|
17
|
+
- file.hasTag("featured")
|
|
18
|
+
properties:
|
|
19
|
+
file.name:
|
|
20
|
+
displayName: Title
|
|
21
|
+
file.tags:
|
|
22
|
+
displayName: Tags
|
|
23
|
+
views:
|
|
24
|
+
- type: table
|
|
25
|
+
name: Featured
|
|
26
|
+
order:
|
|
27
|
+
- file.name
|
|
28
|
+
- file.tags
|
|
29
|
+
limit: 10
|
|
30
|
+
```
|
|
31
|
+
````
|
|
32
|
+
|
|
33
|
+
and renders them using the content manifest (every note's frontmatter, tags,
|
|
34
|
+
links, and permalink).
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { defineConfig } from "@riebeckite/core";
|
|
40
|
+
import { bases } from "@riebeckite/plugin-bases";
|
|
41
|
+
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
// ...
|
|
44
|
+
plugins: [bases()],
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Block syntax
|
|
49
|
+
|
|
50
|
+
The block body is an Obsidian Base YAML document.
|
|
51
|
+
|
|
52
|
+
| Field | Type | Description |
|
|
53
|
+
| ----- | ---- | ----------- |
|
|
54
|
+
| `filters` | expression \| list \| object | Top-level filter applied to every view (below) |
|
|
55
|
+
| `properties` | object | Property id -> display name (or `{ displayName }`) |
|
|
56
|
+
| `views` | object[] | One or more views |
|
|
57
|
+
|
|
58
|
+
### Views
|
|
59
|
+
|
|
60
|
+
| Field | Type | Description |
|
|
61
|
+
| ----- | ---- | ----------- |
|
|
62
|
+
| `type` | `"table"` \| `"cards"` | Output kind. Defaults to `table` |
|
|
63
|
+
| `name` | string | Optional label rendered above the view |
|
|
64
|
+
| `filters` | filter | Additional filter, combined with the top-level filter using AND |
|
|
65
|
+
| `order` | string \| string[] | Columns (property ids) and their display order |
|
|
66
|
+
| `columns` | string \| string[] | Alias for `order` |
|
|
67
|
+
| `sort` | object \| object[] \| string | Sort keys (below) |
|
|
68
|
+
| `limit` | number | Row cap for this view; still bounded by the `limit` option |
|
|
69
|
+
|
|
70
|
+
`sort` accepts the Core shape `{ field, order }`, the Obsidian shape
|
|
71
|
+
`{ property, direction }`, or a shorthand string (`"-file.name"` sorts
|
|
72
|
+
descending). When a view omits `order`/`columns`, the columns are the keys of
|
|
73
|
+
`properties` (in order), or `["file.name", "file.tags"]`.
|
|
74
|
+
|
|
75
|
+
### Filter grammar
|
|
76
|
+
|
|
77
|
+
A filter is an expression string, a list of expressions (treated as AND), or an
|
|
78
|
+
object with `and` / `or` / `not` keys. `and` and `or` take a list; `not` takes an
|
|
79
|
+
expression or a list (the list is ANDed, then negated). A plain object whose keys
|
|
80
|
+
are property names is treated as equality.
|
|
81
|
+
|
|
82
|
+
| Expression | Description |
|
|
83
|
+
| ---------- | ----------- |
|
|
84
|
+
| `file.hasTag("x")` | Has the tag `x` (or a subtag `x/...`). Case-insensitive |
|
|
85
|
+
| `file.inFolder("x")` | Slug equals `x` or starts with `x/` |
|
|
86
|
+
| `file.hasLink("x")` | Links to `x` (by resolved slug, raw target, or file name) |
|
|
87
|
+
| `file.name` / `file.title` | Note title |
|
|
88
|
+
| `file.path` / `file.slug` | Slug |
|
|
89
|
+
| `file.folder` | Parent folder of the slug |
|
|
90
|
+
| `file.link` / `file.permalink` | Permalink |
|
|
91
|
+
| `file.tags` | Tags |
|
|
92
|
+
| `note.key` / `key` | A frontmatter value |
|
|
93
|
+
|
|
94
|
+
Comparisons use `==`, `!=`, `>`, `<`, `>=`, `<=`, and `contains`. String
|
|
95
|
+
comparisons are case-insensitive; `contains` tests array membership or substring
|
|
96
|
+
containment. Bare scalar lists are ANDed.
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
filters:
|
|
100
|
+
and:
|
|
101
|
+
- file.hasTag("featured")
|
|
102
|
+
- or:
|
|
103
|
+
- note.status == "published"
|
|
104
|
+
- note.status == "review"
|
|
105
|
+
- not:
|
|
106
|
+
- file.hasTag("draft")
|
|
107
|
+
views:
|
|
108
|
+
- type: table
|
|
109
|
+
name: Featured
|
|
110
|
+
order: [file.name, note.status]
|
|
111
|
+
sort:
|
|
112
|
+
- property: file.name
|
|
113
|
+
direction: ASC
|
|
114
|
+
limit: 20
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Options
|
|
118
|
+
|
|
119
|
+
| Option | Type | Default | Description |
|
|
120
|
+
| ------ | ---- | ------- | ----------- |
|
|
121
|
+
| `className` | `string` | `"rb-bases"` | Root CSS class |
|
|
122
|
+
| `language` | `string` | `"base"` | Fence language to target |
|
|
123
|
+
| `limit` | `number` | `100` | Global row cap applied to every view |
|
|
124
|
+
| `showFallback` | `boolean` | `true` | Render the raw Base definition in a `<details>` fallback |
|
|
125
|
+
| `view` | `string` | none | Render only the view with this name when a Base defines several |
|
|
126
|
+
|
|
127
|
+
## Output HTML / CSS hooks
|
|
128
|
+
|
|
129
|
+
```html
|
|
130
|
+
<div class="rb-bases" data-bases data-bases-view="table">
|
|
131
|
+
<section class="rb-bases__view" data-bases-view="table">
|
|
132
|
+
<h3 class="rb-bases__view-name">Featured</h3>
|
|
133
|
+
<table class="rb-bases__table"> ... </table>
|
|
134
|
+
</section>
|
|
135
|
+
<details class="rb-bases__fallback"> ... </details>
|
|
136
|
+
</div>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Stable classes: `rb-bases`, `rb-bases__view`, `rb-bases__view-name`,
|
|
140
|
+
`rb-bases__table`, `rb-bases__heading`, `rb-bases__cell`, `rb-bases__row`,
|
|
141
|
+
`rb-bases__link`, `rb-bases__tags`, `rb-bases__tag`, `rb-bases__cards`,
|
|
142
|
+
`rb-bases__card`, `rb-bases__card-title`, `rb-bases__fields`, `rb-bases__field`,
|
|
143
|
+
`rb-bases__field-label`, `rb-bases__field-value`, `rb-bases__empty`,
|
|
144
|
+
`rb-bases__fallback`, `rb-bases--error`. Stable attributes: `data-bases`,
|
|
145
|
+
`data-bases-view`.
|
|
146
|
+
|
|
147
|
+
## Diagnostics
|
|
148
|
+
|
|
149
|
+
A block that is not valid YAML, or that uses an unsupported filter expression or
|
|
150
|
+
view shape, is left as a code block and reported through `file.message(...)` with
|
|
151
|
+
`source: "@riebeckite/plugin-bases"`.
|
|
152
|
+
|
|
153
|
+
## Limitations
|
|
154
|
+
|
|
155
|
+
This is an MVP subset of Obsidian Bases:
|
|
156
|
+
|
|
157
|
+
- Only the `table` and `cards` view types are rendered.
|
|
158
|
+
- Inline boolean operators (`&&`, `||`, `!`) are not supported; use the
|
|
159
|
+
`and` / `or` / `not` YAML structure.
|
|
160
|
+
- `if()` / `filter()` and other Base formula functions are not supported.
|
|
161
|
+
- Nested property paths and `file.mtime` / `file.ctime` are mapped onto `date`.
|
|
162
|
+
- Property-to-property comparisons are not supported; the right-hand side is a
|
|
163
|
+
literal.
|
|
164
|
+
- Results are fixed at build time. Rebuilding a host note when a queried note
|
|
165
|
+
changes is future work; a full build always recomputes correctly.
|
|
166
|
+
|
|
167
|
+
## Exports
|
|
168
|
+
|
|
169
|
+
- `bases(options?)` — plugin factory (alias: `basesPlugin`)
|
|
170
|
+
- `remarkBases(options?)` — remark transform usable on its own (`options.language`
|
|
171
|
+
selects the fence language)
|
|
172
|
+
- `parseBases(document)` — compiles a parsed YAML Base document to a spec
|
|
173
|
+
- `matchesCondition(condition, entry)` — condition evaluator
|
|
174
|
+
- Types: `BasesOptions`, `BasesSpec`, `BasesView`, `BasesViewType`,
|
|
175
|
+
`BasesCondition`, `BasesValueRef`, `BasesBuiltinValue`, `BasesOperator`,
|
|
176
|
+
`BasesLiteral`
|
|
177
|
+
|
|
178
|
+
## See also
|
|
179
|
+
|
|
180
|
+
- [Plugin guide](../../../docs/en/reference/plugin-api.md)
|
package/README_ja.md
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
# @riebeckite/plugin-bases
|
|
2
|
-
|
|
3
|
-
フェンスコードブロック `base` に書いた Obsidian Bases 定義を HTML にレンダリングします。フィルタ・ソート・ビューの組み立てはビルド時にコンテンツマニフェストに対して行われるため、クライアントサイド JavaScript は不要です。
|
|
4
|
-
|
|
5
|
-
[English](./README.md)
|
|
6
|
-
|
|
7
|
-
## 概要
|
|
8
|
-
|
|
9
|
-
`bases()` は次のようなフェンスブロックを認識します。
|
|
10
|
-
|
|
11
|
-
````md
|
|
12
|
-
```base
|
|
13
|
-
filters:
|
|
14
|
-
and:
|
|
15
|
-
- file.hasTag("featured")
|
|
16
|
-
properties:
|
|
17
|
-
file.name:
|
|
18
|
-
displayName: Title
|
|
19
|
-
file.tags:
|
|
20
|
-
displayName: Tags
|
|
21
|
-
views:
|
|
22
|
-
- type: table
|
|
23
|
-
name: Featured
|
|
24
|
-
order:
|
|
25
|
-
- file.name
|
|
26
|
-
- file.tags
|
|
27
|
-
limit: 10
|
|
28
|
-
```
|
|
29
|
-
````
|
|
30
|
-
|
|
31
|
-
レンダリングにはコンテンツマニフェスト(各ノートの frontmatter・タグ・リンク・パーマリンク)を使います。
|
|
32
|
-
|
|
33
|
-
## 使い方
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import { defineConfig } from "@riebeckite/core";
|
|
37
|
-
import { bases } from "@riebeckite/plugin-bases";
|
|
38
|
-
|
|
39
|
-
export default defineConfig({
|
|
40
|
-
// ...
|
|
41
|
-
plugins: [bases()],
|
|
42
|
-
});
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## ブロックの構文
|
|
46
|
-
|
|
47
|
-
ブロック本体は Obsidian Base の YAML ドキュメントです。
|
|
48
|
-
|
|
49
|
-
| フィールド | 型 | 説明 |
|
|
50
|
-
| ---------- | -- | ---- |
|
|
51
|
-
| `filters` | 式 \| リスト \| オブジェクト | 全ビューに適用するトップレベルフィルタ(後述) |
|
|
52
|
-
| `properties` | オブジェクト | プロパティ ID → 表示名(または `{ displayName }`) |
|
|
53
|
-
| `views` | オブジェクト[] | 1 つ以上のビュー |
|
|
54
|
-
|
|
55
|
-
### ビュー
|
|
56
|
-
|
|
57
|
-
| フィールド | 型 | 説明 |
|
|
58
|
-
| ---------- | -- | ---- |
|
|
59
|
-
| `type` | `"table"` \| `"cards"` | 出力形式。既定は `table` |
|
|
60
|
-
| `name` | string | ビュー上部に表示する任意のラベル |
|
|
61
|
-
| `filters` | フィルタ | トップレベルフィルタに AND で合成する追加フィルタ |
|
|
62
|
-
| `order` | string \| string[] | 列(プロパティ ID)と表示順 |
|
|
63
|
-
| `columns` | string \| string[] | `order` の別名 |
|
|
64
|
-
| `sort` | オブジェクト \| オブジェクト[] \| string | ソートキー(後述) |
|
|
65
|
-
| `limit` | number | このビューの行数上限。`limit` オプション以下に制限される |
|
|
66
|
-
|
|
67
|
-
`sort` は Core 形式 `{ field, order }`、Obsidian 形式 `{ property, direction }`、短縮文字列(`"-file.name"` で降順)のいずれかを受け付けます。ビューに `order` / `columns` がない場合、列は `properties` のキー(定義順)、それもなければ `["file.name", "file.tags"]` になります。
|
|
68
|
-
|
|
69
|
-
### フィルタの文法
|
|
70
|
-
|
|
71
|
-
フィルタは式文字列、式のリスト(AND として扱う)、または `and` / `or` / `not` を持つオブジェクトです。`and` と `or` はリストを取り、`not` は式またはリスト(リストは AND でまとめてから否定)を取ります。プロパティ名をキーにした素のオブジェクトは等価比較として扱います。
|
|
72
|
-
|
|
73
|
-
| 式 | 説明 |
|
|
74
|
-
| -- | ---- |
|
|
75
|
-
| `file.hasTag("x")` | タグ `x`(またはサブタグ `x/...`)を持つ。大文字小文字は区別しない |
|
|
76
|
-
| `file.inFolder("x")` | スラグが `x` に一致するか `x/` で始まる |
|
|
77
|
-
| `file.hasLink("x")` | `x` へのリンクがある(解決済みスラグ・生のターゲット・ファイル名で照合) |
|
|
78
|
-
| `file.name` / `file.title` | ノートのタイトル |
|
|
79
|
-
| `file.path` / `file.slug` | スラグ |
|
|
80
|
-
| `file.folder` | スラグの親フォルダ |
|
|
81
|
-
| `file.link` / `file.permalink` | パーマリンク |
|
|
82
|
-
| `file.tags` | タグ |
|
|
83
|
-
| `note.key` / `key` | frontmatter の値 |
|
|
84
|
-
|
|
85
|
-
比較演算子は `==`、`!=`、`>`、`<`、`>=`、`<=`、`contains` です。文字列比較は大文字小文字を区別せず、`contains` は配列の要素または文字列の部分一致を調べます。スカラーのリストは AND として扱います。
|
|
86
|
-
|
|
87
|
-
```yaml
|
|
88
|
-
filters:
|
|
89
|
-
and:
|
|
90
|
-
- file.hasTag("featured")
|
|
91
|
-
- or:
|
|
92
|
-
- note.status == "published"
|
|
93
|
-
- note.status == "review"
|
|
94
|
-
- not:
|
|
95
|
-
- file.hasTag("draft")
|
|
96
|
-
views:
|
|
97
|
-
- type: table
|
|
98
|
-
name: Featured
|
|
99
|
-
order: [file.name, note.status]
|
|
100
|
-
sort:
|
|
101
|
-
- property: file.name
|
|
102
|
-
direction: ASC
|
|
103
|
-
limit: 20
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## オプション
|
|
107
|
-
|
|
108
|
-
| オプション | 型 | 既定値 | 説明 |
|
|
109
|
-
| ---------- | -- | ------ | ---- |
|
|
110
|
-
| `className` | `string` | `"rb-bases"` | ルート CSS クラス |
|
|
111
|
-
| `language` | `string` | `"base"` | 対象とするフェンス言語 |
|
|
112
|
-
| `limit` | `number` | `100` | 全ビューに適用する行数上限 |
|
|
113
|
-
| `showFallback` | `boolean` | `true` | 生の Base 定義を `<details>` のフォールバックに表示する |
|
|
114
|
-
| `view` | `string` | なし | Base に複数ビューがあるとき、指定名のビューだけをレンダリングする |
|
|
115
|
-
|
|
116
|
-
## 出力 HTML / CSS フック
|
|
117
|
-
|
|
118
|
-
```html
|
|
119
|
-
<div class="rb-bases" data-bases data-bases-view="table">
|
|
120
|
-
<section class="rb-bases__view" data-bases-view="table">
|
|
121
|
-
<h3 class="rb-bases__view-name">Featured</h3>
|
|
122
|
-
<table class="rb-bases__table"> ... </table>
|
|
123
|
-
</section>
|
|
124
|
-
<details class="rb-bases__fallback"> ... </details>
|
|
125
|
-
</div>
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
安定クラス: `rb-bases`、`rb-bases__view`、`rb-bases__view-name`、`rb-bases__table`、`rb-bases__heading`、`rb-bases__cell`、`rb-bases__row`、`rb-bases__link`、`rb-bases__tags`、`rb-bases__tag`、`rb-bases__cards`、`rb-bases__card`、`rb-bases__card-title`、`rb-bases__fields`、`rb-bases__field`、`rb-bases__field-label`、`rb-bases__field-value`、`rb-bases__empty`、`rb-bases__fallback`、`rb-bases--error`。安定属性: `data-bases`、`data-bases-view`。
|
|
129
|
-
|
|
130
|
-
## 診断
|
|
131
|
-
|
|
132
|
-
YAML として不正なブロック、未対応のフィルタ式やビュー形状を使ったブロックはコードブロックのまま残し、`source: "@riebeckite/plugin-bases"` を付けて `file.message(...)` で報告します。
|
|
133
|
-
|
|
134
|
-
## 制限事項
|
|
135
|
-
|
|
136
|
-
これは Obsidian Bases の MVP サブセットです。
|
|
137
|
-
|
|
138
|
-
- レンダリングできるのは `table` と `cards` の 2 種類のビューだけです。
|
|
139
|
-
- インラインの論理演算子(`&&`、`||`、`!`)は未対応です。`and` / `or` / `not` の YAML 構造を使ってください。
|
|
140
|
-
- `if()` / `filter()` などの Base フォーミュラ関数は未対応です。
|
|
141
|
-
- ネストしたプロパティパスと `file.mtime` / `file.ctime` は `date` にマップされます。
|
|
142
|
-
- プロパティ同士の比較は未対応で、右辺はリテラルです。
|
|
143
|
-
- 結果はビルド時に確定します。参照先ノートの変更に応じてホストノートだけを再ビルドするのは今後の課題で、フルビルドでは常に正しく再計算されます。
|
|
144
|
-
|
|
145
|
-
## エクスポート
|
|
146
|
-
|
|
147
|
-
- `bases(options?)` — プラグインファクトリ(別名: `basesPlugin`)
|
|
148
|
-
- `remarkBases(options?)` — 単体で使える remark トランスフォーム(`options.language` でフェンス言語を選択)
|
|
149
|
-
- `parseBases(document)` — パース済み YAML Base ドキュメントをスペックにコンパイル
|
|
150
|
-
- `matchesCondition(condition, entry)` — 条件評価関数
|
|
151
|
-
- 型: `BasesOptions`、`BasesSpec`、`BasesView`、`BasesViewType`、`BasesCondition`、`BasesValueRef`、`BasesBuiltinValue`、`BasesOperator`、`BasesLiteral`
|
|
152
|
-
|
|
153
|
-
## 関連
|
|
154
|
-
|
|
155
|
-
- [プラグインガイド](../../../docs/ja/plugin-
|
|
1
|
+
# @riebeckite/plugin-bases
|
|
2
|
+
|
|
3
|
+
フェンスコードブロック `base` に書いた Obsidian Bases 定義を HTML にレンダリングします。フィルタ・ソート・ビューの組み立てはビルド時にコンテンツマニフェストに対して行われるため、クライアントサイド JavaScript は不要です。
|
|
4
|
+
|
|
5
|
+
[English](./README.md)
|
|
6
|
+
|
|
7
|
+
## 概要
|
|
8
|
+
|
|
9
|
+
`bases()` は次のようなフェンスブロックを認識します。
|
|
10
|
+
|
|
11
|
+
````md
|
|
12
|
+
```base
|
|
13
|
+
filters:
|
|
14
|
+
and:
|
|
15
|
+
- file.hasTag("featured")
|
|
16
|
+
properties:
|
|
17
|
+
file.name:
|
|
18
|
+
displayName: Title
|
|
19
|
+
file.tags:
|
|
20
|
+
displayName: Tags
|
|
21
|
+
views:
|
|
22
|
+
- type: table
|
|
23
|
+
name: Featured
|
|
24
|
+
order:
|
|
25
|
+
- file.name
|
|
26
|
+
- file.tags
|
|
27
|
+
limit: 10
|
|
28
|
+
```
|
|
29
|
+
````
|
|
30
|
+
|
|
31
|
+
レンダリングにはコンテンツマニフェスト(各ノートの frontmatter・タグ・リンク・パーマリンク)を使います。
|
|
32
|
+
|
|
33
|
+
## 使い方
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { defineConfig } from "@riebeckite/core";
|
|
37
|
+
import { bases } from "@riebeckite/plugin-bases";
|
|
38
|
+
|
|
39
|
+
export default defineConfig({
|
|
40
|
+
// ...
|
|
41
|
+
plugins: [bases()],
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## ブロックの構文
|
|
46
|
+
|
|
47
|
+
ブロック本体は Obsidian Base の YAML ドキュメントです。
|
|
48
|
+
|
|
49
|
+
| フィールド | 型 | 説明 |
|
|
50
|
+
| ---------- | -- | ---- |
|
|
51
|
+
| `filters` | 式 \| リスト \| オブジェクト | 全ビューに適用するトップレベルフィルタ(後述) |
|
|
52
|
+
| `properties` | オブジェクト | プロパティ ID → 表示名(または `{ displayName }`) |
|
|
53
|
+
| `views` | オブジェクト[] | 1 つ以上のビュー |
|
|
54
|
+
|
|
55
|
+
### ビュー
|
|
56
|
+
|
|
57
|
+
| フィールド | 型 | 説明 |
|
|
58
|
+
| ---------- | -- | ---- |
|
|
59
|
+
| `type` | `"table"` \| `"cards"` | 出力形式。既定は `table` |
|
|
60
|
+
| `name` | string | ビュー上部に表示する任意のラベル |
|
|
61
|
+
| `filters` | フィルタ | トップレベルフィルタに AND で合成する追加フィルタ |
|
|
62
|
+
| `order` | string \| string[] | 列(プロパティ ID)と表示順 |
|
|
63
|
+
| `columns` | string \| string[] | `order` の別名 |
|
|
64
|
+
| `sort` | オブジェクト \| オブジェクト[] \| string | ソートキー(後述) |
|
|
65
|
+
| `limit` | number | このビューの行数上限。`limit` オプション以下に制限される |
|
|
66
|
+
|
|
67
|
+
`sort` は Core 形式 `{ field, order }`、Obsidian 形式 `{ property, direction }`、短縮文字列(`"-file.name"` で降順)のいずれかを受け付けます。ビューに `order` / `columns` がない場合、列は `properties` のキー(定義順)、それもなければ `["file.name", "file.tags"]` になります。
|
|
68
|
+
|
|
69
|
+
### フィルタの文法
|
|
70
|
+
|
|
71
|
+
フィルタは式文字列、式のリスト(AND として扱う)、または `and` / `or` / `not` を持つオブジェクトです。`and` と `or` はリストを取り、`not` は式またはリスト(リストは AND でまとめてから否定)を取ります。プロパティ名をキーにした素のオブジェクトは等価比較として扱います。
|
|
72
|
+
|
|
73
|
+
| 式 | 説明 |
|
|
74
|
+
| -- | ---- |
|
|
75
|
+
| `file.hasTag("x")` | タグ `x`(またはサブタグ `x/...`)を持つ。大文字小文字は区別しない |
|
|
76
|
+
| `file.inFolder("x")` | スラグが `x` に一致するか `x/` で始まる |
|
|
77
|
+
| `file.hasLink("x")` | `x` へのリンクがある(解決済みスラグ・生のターゲット・ファイル名で照合) |
|
|
78
|
+
| `file.name` / `file.title` | ノートのタイトル |
|
|
79
|
+
| `file.path` / `file.slug` | スラグ |
|
|
80
|
+
| `file.folder` | スラグの親フォルダ |
|
|
81
|
+
| `file.link` / `file.permalink` | パーマリンク |
|
|
82
|
+
| `file.tags` | タグ |
|
|
83
|
+
| `note.key` / `key` | frontmatter の値 |
|
|
84
|
+
|
|
85
|
+
比較演算子は `==`、`!=`、`>`、`<`、`>=`、`<=`、`contains` です。文字列比較は大文字小文字を区別せず、`contains` は配列の要素または文字列の部分一致を調べます。スカラーのリストは AND として扱います。
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
filters:
|
|
89
|
+
and:
|
|
90
|
+
- file.hasTag("featured")
|
|
91
|
+
- or:
|
|
92
|
+
- note.status == "published"
|
|
93
|
+
- note.status == "review"
|
|
94
|
+
- not:
|
|
95
|
+
- file.hasTag("draft")
|
|
96
|
+
views:
|
|
97
|
+
- type: table
|
|
98
|
+
name: Featured
|
|
99
|
+
order: [file.name, note.status]
|
|
100
|
+
sort:
|
|
101
|
+
- property: file.name
|
|
102
|
+
direction: ASC
|
|
103
|
+
limit: 20
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## オプション
|
|
107
|
+
|
|
108
|
+
| オプション | 型 | 既定値 | 説明 |
|
|
109
|
+
| ---------- | -- | ------ | ---- |
|
|
110
|
+
| `className` | `string` | `"rb-bases"` | ルート CSS クラス |
|
|
111
|
+
| `language` | `string` | `"base"` | 対象とするフェンス言語 |
|
|
112
|
+
| `limit` | `number` | `100` | 全ビューに適用する行数上限 |
|
|
113
|
+
| `showFallback` | `boolean` | `true` | 生の Base 定義を `<details>` のフォールバックに表示する |
|
|
114
|
+
| `view` | `string` | なし | Base に複数ビューがあるとき、指定名のビューだけをレンダリングする |
|
|
115
|
+
|
|
116
|
+
## 出力 HTML / CSS フック
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<div class="rb-bases" data-bases data-bases-view="table">
|
|
120
|
+
<section class="rb-bases__view" data-bases-view="table">
|
|
121
|
+
<h3 class="rb-bases__view-name">Featured</h3>
|
|
122
|
+
<table class="rb-bases__table"> ... </table>
|
|
123
|
+
</section>
|
|
124
|
+
<details class="rb-bases__fallback"> ... </details>
|
|
125
|
+
</div>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
安定クラス: `rb-bases`、`rb-bases__view`、`rb-bases__view-name`、`rb-bases__table`、`rb-bases__heading`、`rb-bases__cell`、`rb-bases__row`、`rb-bases__link`、`rb-bases__tags`、`rb-bases__tag`、`rb-bases__cards`、`rb-bases__card`、`rb-bases__card-title`、`rb-bases__fields`、`rb-bases__field`、`rb-bases__field-label`、`rb-bases__field-value`、`rb-bases__empty`、`rb-bases__fallback`、`rb-bases--error`。安定属性: `data-bases`、`data-bases-view`。
|
|
129
|
+
|
|
130
|
+
## 診断
|
|
131
|
+
|
|
132
|
+
YAML として不正なブロック、未対応のフィルタ式やビュー形状を使ったブロックはコードブロックのまま残し、`source: "@riebeckite/plugin-bases"` を付けて `file.message(...)` で報告します。
|
|
133
|
+
|
|
134
|
+
## 制限事項
|
|
135
|
+
|
|
136
|
+
これは Obsidian Bases の MVP サブセットです。
|
|
137
|
+
|
|
138
|
+
- レンダリングできるのは `table` と `cards` の 2 種類のビューだけです。
|
|
139
|
+
- インラインの論理演算子(`&&`、`||`、`!`)は未対応です。`and` / `or` / `not` の YAML 構造を使ってください。
|
|
140
|
+
- `if()` / `filter()` などの Base フォーミュラ関数は未対応です。
|
|
141
|
+
- ネストしたプロパティパスと `file.mtime` / `file.ctime` は `date` にマップされます。
|
|
142
|
+
- プロパティ同士の比較は未対応で、右辺はリテラルです。
|
|
143
|
+
- 結果はビルド時に確定します。参照先ノートの変更に応じてホストノートだけを再ビルドするのは今後の課題で、フルビルドでは常に正しく再計算されます。
|
|
144
|
+
|
|
145
|
+
## エクスポート
|
|
146
|
+
|
|
147
|
+
- `bases(options?)` — プラグインファクトリ(別名: `basesPlugin`)
|
|
148
|
+
- `remarkBases(options?)` — 単体で使える remark トランスフォーム(`options.language` でフェンス言語を選択)
|
|
149
|
+
- `parseBases(document)` — パース済み YAML Base ドキュメントをスペックにコンパイル
|
|
150
|
+
- `matchesCondition(condition, entry)` — 条件評価関数
|
|
151
|
+
- 型: `BasesOptions`、`BasesSpec`、`BasesView`、`BasesViewType`、`BasesCondition`、`BasesValueRef`、`BasesBuiltinValue`、`BasesOperator`、`BasesLiteral`
|
|
152
|
+
|
|
153
|
+
## 関連
|
|
154
|
+
|
|
155
|
+
- [プラグインガイド](../../../docs/ja/reference/plugin-api.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-bases",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@types/mdast": "^4.0.4",
|
|
19
19
|
"unist-util-visit": "^5.1.0",
|
|
20
20
|
"vfile-matter": "^5.0.1",
|
|
21
|
-
"@riebeckite/core": "0.0.
|
|
21
|
+
"@riebeckite/core": "0.0.13"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|