Color mode

Local Graph

Local (nearby notes) graph rendering: a compact radial graph of a note's outgoing links and backlinks.

日本語

Overview

localGraph() provides a LocalGraph component that renders the current note plus its direct links as an SVG radial graph. getLocalGraph() collects the note's note-type outgoing links and backlinks from the manifest, keeps only published neighbors, and caps each direction at MAX_NEIGHBORS_PER_DIRECTION (10) notes.

Relations are tagged per node:

  • current — the selected note (center)
  • outgoing — linked from the current note
  • backlink — links to the current note
  • both — linked in both directions

The component renders nothing when there is no published neighbor.

Usage

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

localGraphPlugin() registers the plugin in the plugin list and bundles style.css into the app stylesheet.

Render the component

tsx
import LocalGraph, { getLocalGraph } from "@riebeckite/plugin-local-graph";
import { config } from "../config";
import { content } from "../content";
import { getArticleTitle } from "../lib/article-title";
 
const manifest = await content.getManifest();
const graph = getLocalGraph({
  manifest,
  config,
  slug,
  resolveTitle: getArticleTitle,
});
 
// ...in your route
return (
  <Article
    footerContent={graph && <LocalGraph graph={graph} />}
  />
);

Graph layout

Node positions come from layoutRadialGraph(): the center node sits at the middle, neighbors are arranged around it by link count; node radius grows with the number of links. Edges are computed by buildGraphEdges(). Node links use each node's resolved permalink; the header opens the full explorer through the internal selection key /explore?note=<slug>.

Exports

  • localGraphPlugin() — plugin factory
  • LocalGraph — SVG graph component (default export of components/local-graph.tsx)
  • getLocalGraph({ manifest, config, slug, resolveTitle }) — builds nearby-note data for a slug (null when the note is absent or unpublished)
  • buildGraphEdges(nodes, visibleSlugs?) — pure edge builder
  • layoutRadialGraph(nodes, options) — pure radial layout
  • Types: LocalGraphData, LocalGraphNode

See also

History

1 changesCollapseExpand
1 + <!-- Generated from packages/plugins/local-graph/README.md. Do not edit this page directly; edit the package README and run `pnpm docs:sync`. -->
2 +
3 + # Local Graph
4 +
5 + Local (nearby notes) graph rendering: a compact radial graph of a note's
6 + outgoing links and backlinks.
7 +
8 + [日本語](./local-graph.md)
9 +
10 + ## Overview
11 +
12 + `localGraph()` provides a `LocalGraph` component that renders the current note
13 + plus its direct links as an SVG radial graph. `getLocalGraph()` collects the
14 + note's note-type outgoing links and backlinks from the manifest, keeps only
15 + published neighbors, and caps each direction at `MAX_NEIGHBORS_PER_DIRECTION`
16 + (10) notes.
17 +
18 + Relations are tagged per node:
19 +
20 + - `current` — the selected note (center)
21 + - `outgoing` — linked from the current note
22 + - `backlink` — links to the current note
23 + - `both` — linked in both directions
24 +
25 + The component renders nothing when there is no published neighbor.
26 +
27 + ## Usage
28 +
29 + ```ts
30 + import { defineConfig } from "@riebeckite/core";
31 + import { localGraphPlugin } from "@riebeckite/plugin-local-graph";
32 +
33 + export default defineConfig({
34 + // ...
35 + plugins: [localGraphPlugin()],
36 + });
37 + ```
38 +
39 + `localGraphPlugin()` registers the plugin in the plugin list and bundles
40 + `style.css` into the app stylesheet.
41 +
42 + ### Render the component
43 +
44 + ```tsx
45 + import LocalGraph, { getLocalGraph } from "@riebeckite/plugin-local-graph";
46 + import { config } from "../config";
47 + import { content } from "../content";
48 + import { getArticleTitle } from "../lib/article-title";
49 +
50 + const manifest = await content.getManifest();
51 + const graph = getLocalGraph({
52 + manifest,
53 + config,
54 + slug,
55 + resolveTitle: getArticleTitle,
56 + });
57 +
58 + // ...in your route
59 + return (
60 + <Article
61 + footerContent={graph && <LocalGraph graph={graph} />}
62 + />
63 + );
64 + ```
65 +
66 + ## Graph layout
67 +
68 + Node positions come from `layoutRadialGraph()`: the center node sits at the
69 + middle, neighbors are arranged around it by link count; node radius grows with
70 + the number of links. Edges are computed by `buildGraphEdges()`. Node links use
71 + each node's resolved `permalink`; the header opens the full explorer through the
72 + internal selection key `/explore?note=<slug>`.
73 +
74 + ## Exports
75 +
76 + - `localGraphPlugin()` — plugin factory
77 + - `LocalGraph` — SVG graph component (default export of `components/local-graph.tsx`)
78 + - `getLocalGraph({ manifest, config, slug, resolveTitle })` — builds nearby-note
79 + data for a slug (`null` when the note is absent or unpublished)
80 + - `buildGraphEdges(nodes, visibleSlugs?)` — pure edge builder
81 + - `layoutRadialGraph(nodes, options)` — pure radial layout
82 + - Types: `LocalGraphData`, `LocalGraphNode`
83 +
84 + ## See also
85 +
86 + - [Plugin guide](../reference/plugin-api.en.md)
87 + - [`@riebeckite/plugin-backlinks`](./backlinks.en.md)
88 + - [`@riebeckite/plugin-garden-explorer`](./garden-explorer.en.md)
89 +