@riebeckite/plugin-query 0.0.14 → 0.0.15
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 +2 -1
- package/README_ja.md +7 -6
- package/dist/index.js +7 -11
- package/dist/src/runtime.d.ts +1 -2
- package/package.json +3 -3
package/README.md
CHANGED
package/README_ja.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @riebeckite/plugin-query
|
|
2
2
|
|
|
3
|
-
`query`
|
|
3
|
+
`query` コードブロックを、コンテンツの一覧(表またはリスト)に変換するプラグインです。絞り込み・並べ替え・件数制限を frontmatter とタグに対して行い、ビルド時に HTML を生成します。クライアント側の JavaScript は不要です。
|
|
4
4
|
|
|
5
5
|
[English](./README.md)
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ limit: 5
|
|
|
20
20
|
```
|
|
21
21
|
````
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
を検出し、マニフェスト(全ノートの frontmatter・タグ・パーマリンク)を使って結果を描画します。
|
|
24
24
|
|
|
25
25
|
## 設定
|
|
26
26
|
|
|
@@ -41,11 +41,11 @@ export default defineConfig({
|
|
|
41
41
|
| フィールド | 型 | 内容 |
|
|
42
42
|
| --- | --- | --- |
|
|
43
43
|
| `filter` | object | 絞り込み条件(下記) |
|
|
44
|
-
| `sort` | object \| object[] | 並べ替え。`field
|
|
44
|
+
| `sort` | object \| object[] | 並べ替え。`field`(frontmatter キー、`title`、`slug`、`permalink`)と `order`(`asc` / `desc`、既定 `asc`)。既定のフィールドは `date` |
|
|
45
45
|
| `limit` | number | 最大件数 |
|
|
46
46
|
| `offset` | number | 先頭から読み飛ばす件数 |
|
|
47
47
|
| `format` | `"table"` \| `"list"` | 表示形式。既定は `table` |
|
|
48
|
-
| `columns` | string[] | 表の列。プリセット(`title`、`date`、`updated`、`created`、`published`、`tags`、`description`、`permalink
|
|
48
|
+
| `columns` | string[] | 表の列。プリセット(`title`、`date`、`updated`、`created`、`published`、`tags`、`description`、`permalink`)または frontmatter キー |
|
|
49
49
|
| `excludeSelf` | boolean | このブロックを含むノート自身を結果から除く |
|
|
50
50
|
| `empty` | string | 一致が無いときのメッセージ |
|
|
51
51
|
|
|
@@ -57,7 +57,7 @@ export default defineConfig({
|
|
|
57
57
|
| `tags.all` | string[] | すべてのタグを持つ |
|
|
58
58
|
| `tags.none` | string[] | どのタグも持たない |
|
|
59
59
|
| `folder` | string \| string[] | スラッグの前方一致 |
|
|
60
|
-
| `frontmatter` | object |
|
|
60
|
+
| `frontmatter` | object | frontmatter の一致。値が配列ならそのいずれかに一致。文字列比較は大文字小文字を区別しない |
|
|
61
61
|
| `date` | object | `field`(既定 `date`)と `from` / `to`(両端を含む) |
|
|
62
62
|
|
|
63
63
|
```yaml
|
|
@@ -111,4 +111,5 @@ format: list
|
|
|
111
111
|
|
|
112
112
|
## 関連資料
|
|
113
113
|
|
|
114
|
-
- [プラグインシステム](../../../docs/ja/reference/plugin-api.md)
|
|
114
|
+
- [プラグインシステム](../../../docs/ja/docs/reference/plugin-api.md)
|
|
115
|
+
|
package/dist/index.js
CHANGED
|
@@ -184,20 +184,14 @@ var KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
|
184
184
|
"empty"
|
|
185
185
|
]);
|
|
186
186
|
function createQueryRuntime(options) {
|
|
187
|
-
const tracked = /* @__PURE__ */ new Map();
|
|
188
187
|
return {
|
|
189
|
-
track(slug, content) {
|
|
190
|
-
tracked.set(slug, content);
|
|
191
|
-
},
|
|
192
188
|
resolve(manifest, diagnostics) {
|
|
193
|
-
const entries = manifest.
|
|
194
|
-
for (const entry of
|
|
189
|
+
const entries = manifest.discoverableEntries;
|
|
190
|
+
for (const entry of manifest.publicEntries) {
|
|
195
191
|
if (!entry.html.includes(QUERY_ATTRIBUTE)) continue;
|
|
196
192
|
const html = replacePlaceholders(entry, entries, options, diagnostics);
|
|
197
193
|
if (html === entry.html) continue;
|
|
198
194
|
entry.html = html;
|
|
199
|
-
const content = tracked.get(entry.slug);
|
|
200
|
-
if (content) content.html = html;
|
|
201
195
|
}
|
|
202
196
|
}
|
|
203
197
|
};
|
|
@@ -289,15 +283,17 @@ function queryPlugin(options = {}) {
|
|
|
289
283
|
const runtime = createQueryRuntime(options);
|
|
290
284
|
return definePlugin({
|
|
291
285
|
name: "query",
|
|
286
|
+
processedContentCache: {
|
|
287
|
+
version: "query-v1",
|
|
288
|
+
dependencyMode: "none"
|
|
289
|
+
},
|
|
290
|
+
outputDependencies: [{ type: "global" }],
|
|
292
291
|
options,
|
|
293
292
|
provides: ["content.query"],
|
|
294
293
|
validateOptions: validateQueryOptions,
|
|
295
294
|
extendMarkdownPipeline: (pipeline) => {
|
|
296
295
|
pipeline.use(remarkQuery, { language });
|
|
297
296
|
},
|
|
298
|
-
onPostProcessed: (context) => {
|
|
299
|
-
runtime.track(context.slug, context.content);
|
|
300
|
-
},
|
|
301
297
|
onManifestCreated: (context) => {
|
|
302
298
|
runtime.resolve(context.manifest, context.diagnostics);
|
|
303
299
|
},
|
package/dist/src/runtime.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { ContentManifest, Diagnostic
|
|
1
|
+
import type { ContentManifest, Diagnostic } from "@riebeckite/core";
|
|
2
2
|
import type { QueryOptions } from "./types.js";
|
|
3
3
|
export type QueryRuntime = {
|
|
4
|
-
track(slug: string, content: PostContent): void;
|
|
5
4
|
resolve(manifest: ContentManifest, diagnostics: Diagnostic[]): void;
|
|
6
5
|
};
|
|
7
6
|
export declare function createQueryRuntime(options: QueryOptions): QueryRuntime;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-query",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,11 +18,11 @@
|
|
|
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.15"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"tsx": "^4.22.4",
|
|
25
|
-
"@riebeckite/test": "0.0.
|
|
25
|
+
"@riebeckite/test": "0.0.15"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|