@riebeckite/plugin-local-graph 0.0.20 → 0.0.22

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 CHANGED
@@ -1,11 +1,13 @@
1
1
  # @riebeckite/plugin-local-graph
2
2
 
3
+ <!-- Generated from docs/docs/plugins/local-graph.md. Edit the canonical documentation in docs/docs/plugins and run `pnpm docs:sync`. -->
4
+
3
5
  Local (nearby notes) graph rendering: a compact radial graph of a note's
4
6
  outgoing links and backlinks.
5
7
 
6
8
  [日本語](./README_ja.md)
7
9
 
8
- ## Overview
10
+ ## Recommended placement
9
11
 
10
12
  `localGraph()` provides a `LocalGraph` component that renders the current note
11
13
  plus its direct links as an SVG radial graph. `getLocalGraph()` collects the
@@ -22,7 +24,11 @@ Relations are tagged per node:
22
24
 
23
25
  The component renders nothing when there is no published neighbor.
24
26
 
25
- ## Usage
27
+ `localGraphPlugin()` automatically contributes this component to
28
+ `article.footer`. The Site decides where that semantic slot is rendered; the
29
+ official Starter renders it after article content.
30
+
31
+ ## Quick Start
26
32
 
27
33
  ```ts
28
34
  import { defineConfig } from "@riebeckite/core";
@@ -34,15 +40,19 @@ export default defineConfig({
34
40
  });
35
41
  ```
36
42
 
37
- `localGraphPlugin()` registers the plugin in the plugin list and bundles
38
- `style.css` into the app stylesheet.
43
+ `localGraphPlugin()` registers the plugin and bundles `style.css` into the app
44
+ stylesheet. Render `<ContentSlot slots={bodySlots} name="article.footer" />`
45
+ once in the article layout to show automatic output.
46
+
47
+ ## Advanced customization
39
48
 
40
- ### Render the component
49
+ Set `render: false` to use the public data resolver and component in a
50
+ Site-owned location without duplicating the automatic footer. This leaves graph
51
+ generation and published-neighbor filtering intact.
41
52
 
42
53
  ```tsx
43
54
  import LocalGraph, { getLocalGraph } from "@riebeckite/plugin-local-graph";
44
- import { config } from "../config";
45
- import { content } from "../content";
55
+ import { content } from "virtual:riebeckite/content";
46
56
  import { getArticleTitle } from "../lib/article-title";
47
57
 
48
58
  const manifest = await content.getManifest();
@@ -55,12 +65,22 @@ const graph = getLocalGraph({
55
65
 
56
66
  // ...in your route
57
67
  return (
58
- <Article
59
- footerContent={graph && <LocalGraph graph={graph} />}
60
- />
68
+ <aside>{graph && <LocalGraph graph={graph} />}</aside>
61
69
  );
62
70
  ```
63
71
 
72
+ ```ts
73
+ plugins: [localGraphPlugin({ render: false })];
74
+ ```
75
+
76
+ Remove the component to remove manually placed UI.
77
+
78
+ ## Configuration
79
+
80
+ | Option | Type | Default | Description |
81
+ | --- | --- | --- | --- |
82
+ | `render` | `boolean` | `true` | Append the graph to `article.footer`. Set `false` for manual placement. |
83
+
64
84
  ## Graph layout
65
85
 
66
86
  Node positions come from `layoutRadialGraph()`: the center node sits at the
@@ -81,6 +101,6 @@ internal selection key `/explore?note=<slug>`.
81
101
 
82
102
  ## See also
83
103
 
84
- - [Plugin guide](../../../docs/docs/reference/plugin-api.md)
104
+ - [Plugin guide](https://github.com/Rerurate514/riebeckite/blob/main/docs/docs/reference/plugin-api.md)
85
105
  - [`@riebeckite/plugin-backlinks`](../backlinks/README.md)
86
106
  - [`@riebeckite/plugin-garden-explorer`](../garden-explorer/README.md)
package/README_ja.md CHANGED
@@ -1,16 +1,20 @@
1
1
  # @riebeckite/plugin-local-graph
2
2
 
3
+ <!-- Generated from docs/docs/plugins/local-graph.ja.md. Edit the canonical documentation in docs/docs/plugins and run `pnpm docs:sync`. -->
4
+
3
5
  現在のノートと、その前後につながるノートを小さな放射状グラフで表示するプラグインです。
4
6
 
5
7
  [English](./README.md)
6
8
 
7
- ## できること
9
+ ## 推奨配置
8
10
 
9
11
  `getLocalGraph()` はマニフェストからリンク先と被リンク元を集め、公開済みノートだけを残します。各方向は最大 10 件です。`LocalGraph` はそのデータを SVG として描画し、周辺ノートがなければ何も表示しません。
10
12
 
13
+ `localGraphPlugin()` は既定で `article.footer` slot に自動追加します。物理的な位置は Site が決め、公式 Starter は記事本文の後でこの slot を描画します。
14
+
11
15
  ノードには `current`、`outgoing`、`backlink`、`both` の関係が付きます。中央が現在のノート、周囲が直接つながるノートです。
12
16
 
13
- ## 設定と配置
17
+ ## クイックスタート
14
18
 
15
19
  ```ts
16
20
  import { defineConfig } from "@riebeckite/core";
@@ -19,6 +23,12 @@ import { localGraphPlugin } from "@riebeckite/plugin-local-graph";
19
23
  export default defineConfig({ plugins: [localGraphPlugin()] });
20
24
  ```
21
25
 
26
+ 記事レイアウトで `<ContentSlot slots={bodySlots} name="article.footer" />` を一度描画します。
27
+
28
+ ## 高度なカスタマイズ
29
+
30
+ 重複させずに Site 側で配置を決めるには、`render: false` を指定します。グラフの生成と公開済み近傍だけを残すフィルタリングは維持されます。
31
+
22
32
  ```tsx
23
33
  import LocalGraph, { getLocalGraph } from "@riebeckite/plugin-local-graph";
24
34
 
@@ -26,6 +36,16 @@ const graph = getLocalGraph({ manifest: await content.getManifest(), config, slu
26
36
  return <Article footerContent={graph && <LocalGraph graph={graph} />} />;
27
37
  ```
28
38
 
39
+ ```ts
40
+ plugins: [localGraphPlugin({ render: false })];
41
+ ```
42
+
43
+ ## 設定
44
+
45
+ | オプション | 型 | 既定値 | 説明 |
46
+ | --- | --- | --- | --- |
47
+ | `render` | `boolean` | `true` | `article.footer` への自動追加。手動配置では `false`。 |
48
+
29
49
  グラフのノード位置は `layoutRadialGraph()`、辺は `buildGraphEdges()` が計算します。各ノードのリンクは解決済みの `permalink` を使い、見出しは internal selection key `/explore?note=<slug>` で Explorer を開きます。
30
50
 
31
51
  ## 公開 API
@@ -37,7 +57,6 @@ return <Article footerContent={graph && <LocalGraph graph={graph} />} />;
37
57
 
38
58
  ## 関連資料
39
59
 
40
- - [プラグインシステム](../../../docs/docs/reference/plugin-api.ja.md)
60
+ - [プラグインシステム](https://github.com/Rerurate514/riebeckite/blob/main/docs/docs/reference/plugin-api.ja.md)
41
61
  - [`@riebeckite/plugin-backlinks`](../backlinks/README_ja.md)
42
62
  - [`@riebeckite/plugin-garden-explorer`](../garden-explorer/README_ja.md)
43
-
package/dist/index.d.ts CHANGED
@@ -3,4 +3,7 @@ export { default as LocalGraph } from "./components/local-graph.js";
3
3
  export type { LocalGraphData, LocalGraphNode, LocalGraphNodeRelation, } from "./src/local-graph.js";
4
4
  export { getLocalGraph } from "./src/local-graph.server.js";
5
5
  export { buildGraphEdges, layoutRadialGraph };
6
- export declare function localGraphPlugin(): import("@riebeckite/core").RiebeckitePlugin<unknown>;
6
+ export type LocalGraphOptions = {
7
+ render?: boolean;
8
+ };
9
+ export declare function localGraphPlugin(options?: LocalGraphOptions): import("@riebeckite/core").RiebeckitePlugin<LocalGraphOptions>;
package/dist/index.js CHANGED
@@ -185,11 +185,14 @@ function getRelation(slug, currentSlug, outgoing, backlinks) {
185
185
  }
186
186
 
187
187
  // index.ts
188
- function localGraphPlugin() {
188
+ function localGraphPlugin(options = {}) {
189
189
  return definePlugin({
190
190
  name: "local-graph",
191
191
  order: 400,
192
+ options,
193
+ validateOptions: validateLocalGraphOptions,
192
194
  onManifestCreated: ({ config, manifest }) => {
195
+ if (options.render === false) return;
193
196
  if (!config) return;
194
197
  for (const entry of manifest.discoverableEntries) {
195
198
  const graph = getLocalGraph({
@@ -215,6 +218,12 @@ function localGraphPlugin() {
215
218
  ]
216
219
  });
217
220
  }
221
+ function validateLocalGraphOptions(options) {
222
+ if (!options || options.render === void 0 || typeof options.render === "boolean") {
223
+ return [];
224
+ }
225
+ return [{ path: "render", message: "Expected a boolean." }];
226
+ }
218
227
  function resolveTitle(slug, title) {
219
228
  if (typeof title === "string" && title.trim()) return title;
220
229
  return slug.split("/").at(-1) ?? slug;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-local-graph",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "hono": "^4.12.25",
25
- "@riebeckite/core": "0.0.20"
25
+ "@riebeckite/core": "0.0.22"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsx": "^4.22.4",
29
- "@riebeckite/test": "0.0.20"
29
+ "@riebeckite/test": "0.0.22"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"