@riebeckite/plugin-local-graph 0.0.20 → 0.0.21

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
@@ -5,7 +5,7 @@ outgoing links and backlinks.
5
5
 
6
6
  [日本語](./README_ja.md)
7
7
 
8
- ## Overview
8
+ ## Recommended placement
9
9
 
10
10
  `localGraph()` provides a `LocalGraph` component that renders the current note
11
11
  plus its direct links as an SVG radial graph. `getLocalGraph()` collects the
@@ -22,7 +22,11 @@ Relations are tagged per node:
22
22
 
23
23
  The component renders nothing when there is no published neighbor.
24
24
 
25
- ## Usage
25
+ `localGraphPlugin()` automatically contributes this component to
26
+ `article.footer`. The Site decides where that semantic slot is rendered; the
27
+ official Starter renders it after article content.
28
+
29
+ ## Quick Start
26
30
 
27
31
  ```ts
28
32
  import { defineConfig } from "@riebeckite/core";
@@ -34,15 +38,19 @@ export default defineConfig({
34
38
  });
35
39
  ```
36
40
 
37
- `localGraphPlugin()` registers the plugin in the plugin list and bundles
38
- `style.css` into the app stylesheet.
41
+ `localGraphPlugin()` registers the plugin and bundles `style.css` into the app
42
+ stylesheet. Render `<ContentSlot slots={bodySlots} name="article.footer" />`
43
+ once in the article layout to show automatic output.
44
+
45
+ ## Advanced customization
39
46
 
40
- ### Render the component
47
+ Set `render: false` to use the public data resolver and component in a
48
+ Site-owned location without duplicating the automatic footer. This leaves graph
49
+ generation and published-neighbor filtering intact.
41
50
 
42
51
  ```tsx
43
52
  import LocalGraph, { getLocalGraph } from "@riebeckite/plugin-local-graph";
44
- import { config } from "../config";
45
- import { content } from "../content";
53
+ import { content } from "virtual:riebeckite/content";
46
54
  import { getArticleTitle } from "../lib/article-title";
47
55
 
48
56
  const manifest = await content.getManifest();
@@ -55,12 +63,22 @@ const graph = getLocalGraph({
55
63
 
56
64
  // ...in your route
57
65
  return (
58
- <Article
59
- footerContent={graph && <LocalGraph graph={graph} />}
60
- />
66
+ <aside>{graph && <LocalGraph graph={graph} />}</aside>
61
67
  );
62
68
  ```
63
69
 
70
+ ```ts
71
+ plugins: [localGraphPlugin({ render: false })];
72
+ ```
73
+
74
+ Remove the component to remove manually placed UI.
75
+
76
+ ## Configuration
77
+
78
+ | Option | Type | Default | Description |
79
+ | --- | --- | --- | --- |
80
+ | `render` | `boolean` | `true` | Append the graph to `article.footer`. Set `false` for manual placement. |
81
+
64
82
  ## Graph layout
65
83
 
66
84
  Node positions come from `layoutRadialGraph()`: the center node sits at the
package/README_ja.md CHANGED
@@ -4,13 +4,15 @@
4
4
 
5
5
  [English](./README.md)
6
6
 
7
- ## できること
7
+ ## 推奨配置
8
8
 
9
9
  `getLocalGraph()` はマニフェストからリンク先と被リンク元を集め、公開済みノートだけを残します。各方向は最大 10 件です。`LocalGraph` はそのデータを SVG として描画し、周辺ノートがなければ何も表示しません。
10
10
 
11
+ `localGraphPlugin()` は既定で `article.footer` slot に自動追加します。物理的な位置は Site が決め、公式 Starter は記事本文の後でこの slot を描画します。
12
+
11
13
  ノードには `current`、`outgoing`、`backlink`、`both` の関係が付きます。中央が現在のノート、周囲が直接つながるノートです。
12
14
 
13
- ## 設定と配置
15
+ ## クイックスタート
14
16
 
15
17
  ```ts
16
18
  import { defineConfig } from "@riebeckite/core";
@@ -19,6 +21,12 @@ import { localGraphPlugin } from "@riebeckite/plugin-local-graph";
19
21
  export default defineConfig({ plugins: [localGraphPlugin()] });
20
22
  ```
21
23
 
24
+ 記事レイアウトで `<ContentSlot slots={bodySlots} name="article.footer" />` を一度描画します。
25
+
26
+ ## 高度なカスタマイズ
27
+
28
+ 重複させずに Site 側で配置を決めるには、`render: false` を指定します。グラフの生成と公開済み近傍だけを残すフィルタリングは維持されます。
29
+
22
30
  ```tsx
23
31
  import LocalGraph, { getLocalGraph } from "@riebeckite/plugin-local-graph";
24
32
 
@@ -26,6 +34,16 @@ const graph = getLocalGraph({ manifest: await content.getManifest(), config, slu
26
34
  return <Article footerContent={graph && <LocalGraph graph={graph} />} />;
27
35
  ```
28
36
 
37
+ ```ts
38
+ plugins: [localGraphPlugin({ render: false })];
39
+ ```
40
+
41
+ ## 設定
42
+
43
+ | オプション | 型 | 既定値 | 説明 |
44
+ | --- | --- | --- | --- |
45
+ | `render` | `boolean` | `true` | `article.footer` への自動追加。手動配置では `false`。 |
46
+
29
47
  グラフのノード位置は `layoutRadialGraph()`、辺は `buildGraphEdges()` が計算します。各ノードのリンクは解決済みの `permalink` を使い、見出しは internal selection key `/explore?note=<slug>` で Explorer を開きます。
30
48
 
31
49
  ## 公開 API
@@ -40,4 +58,3 @@ return <Article footerContent={graph && <LocalGraph graph={graph} />} />;
40
58
  - [プラグインシステム](../../../docs/docs/reference/plugin-api.ja.md)
41
59
  - [`@riebeckite/plugin-backlinks`](../backlinks/README_ja.md)
42
60
  - [`@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.21",
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.21"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsx": "^4.22.4",
29
- "@riebeckite/test": "0.0.20"
29
+ "@riebeckite/test": "0.0.21"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"