@riebeckite/plugin-docs 0.0.31 → 0.0.33

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
@@ -8,6 +8,10 @@ router or recalculating public URLs from filesystem paths.
8
8
 
9
9
  [日本語](./README_ja.md)
10
10
 
11
+ ## Live example
12
+
13
+ This page is a Docs entry. The Documentation sidebar on the right, the previous/next links below the article, and the [Docs index](/docs/) all come from this plugin.
14
+
11
15
  ## Installation
12
16
 
13
17
  ```sh
@@ -85,7 +89,7 @@ outside-root content does not appear in the sidebar or previous/next sequence.
85
89
 
86
90
  ## Exports
87
91
 
88
- - `docs(options)` / `docsPlugin(options)` — plugin factory
92
+ - `docs(options)` / `docs(options)` — plugin factory
89
93
  - `buildDocsNavigation(entries, options)` — build the framework-independent model
90
94
  - `flattenDocsNavigation(items)` — derive the previous/next sequence
91
95
  - `renderDocsSidebar(...)` and `renderDocsPrevNext(...)` — server HTML renderers
package/README_ja.md CHANGED
@@ -3,11 +3,15 @@
3
3
  <!-- Generated from docs/docs/plugins/docs.ja.md. Edit the canonical documentation in docs/docs/plugins and run `pnpm docs:sync`. -->
4
4
 
5
5
  Riebeckite の Markdown コンテンツから、Docs 用のサイドバーと前後ページリンクを
6
- ビルド時に生成するプラグインです。Docs 専用の router は追加せず、公開 URL も
6
+ ビルド時に生成するプラグインです。Docs 専用のルーターは追加せず、公開 URL も
7
7
  ファイルシステムのパスから再計算しません。
8
8
 
9
9
  [English](./README.md)
10
10
 
11
+ ## 実行例
12
+
13
+ このページは Docs のエントリです。右側の Documentation サイドバー、記事下の前後リンク、[Docs の一覧](/ja/docs/) はすべてこのプラグインが生成しています。
14
+
11
15
  ## インストール
12
16
 
13
17
  ```sh
@@ -34,7 +38,7 @@ export default defineConfig({
34
38
  `root` は Docs として扱うコンテンツサブツリーです。`root: "docs"` の場合、
35
39
  `content/docs/` 配下だけが対象になり、`notes/` や `blog/` には Docs の UI を出しません。
36
40
 
37
- ## Frontmatter
41
+ ## frontmatter
38
42
 
39
43
  ```yaml
40
44
  ---
@@ -47,12 +51,12 @@ sidebar:
47
51
  ---
48
52
  ```
49
53
 
50
- 対応するメタデータは次の通りです。
54
+ 対応するメタデータは次のとおりです。
51
55
 
52
56
  - `label`: ナビゲーションに表示する名前。未指定なら `title`、さらに未指定ならファイル名。
53
- - `order`: 明示的な並び順。未指定の項目は明示された order のあとを title、path の順に並びます。
57
+ - `order`: 明示的な並び順。指定のない項目は、`order` を持つ項目の後に、タイトル、パスの順で並びます。
54
58
  - `hidden`: サイドバーと前後ページリンクから除外します。
55
- - `collapsed`: Theme やクライアント側の拡張のために `data-docs-collapsed` として出力します。
59
+ - `collapsed`: Theme やクライアント側の拡張で使えるよう、`data-docs-collapsed` として出力します。
56
60
 
57
61
  これらのフィールドはすべて任意です。`sidebar` frontmatter のないページも
58
62
  ナビゲーションに表示されます。階層はフォルダ構造に従い、ラベルは `title`、
@@ -60,27 +64,27 @@ sidebar:
60
64
  設定ではなくコンテンツ側に置きます。上書きしたいフィールドだけを指定し、それ
61
65
  以外は Vault に手を入れないでください。
62
66
 
63
- ## Theme との統合
67
+ ## 出力と Theme の統合
64
68
 
65
- Plugin は React ライクな JSX コンポーネントをサイト統合に提供します。
69
+ プラグインは、サイトへ組み込むための React 風の JSX コンポーネントを提供します。
66
70
 
67
71
  - `<DocsSidebar items={...} currentPermalink? label? />` は `details.rb-docs-sidebar-details` と `nav.rb-docs-sidebar` を描画
68
72
  - `<DocsPrevNext previous? next? />` は `nav.rb-docs-prev-next` を描画
69
73
 
70
- クライアント `initDocsSidebar` がサイドバーを畳めるようにします。
74
+ クライアント側の `initDocsSidebar` を使うと、サイドバーを折りたためます。
71
75
 
72
76
  ## l10n と公開の境界
73
77
 
74
78
  `@riebeckite/plugin-l10n` のメタデータがある場合、現在の言語に対応する項目だけで
75
- ナビゲーションを作ります。URL は manifest の解決済み permalink をそのまま使うため、
76
- permalink / alias / rename / l10n の責務を壊しません。
79
+ ナビゲーションを作ります。URL はマニフェストの解決済みパーマリンクをそのまま使うため、
80
+ パーマリンク、エイリアス、リネーム、l10n の扱いはコンテンツ側の責務のままです。
77
81
 
78
82
  公開対象の項目だけを含めます。draft、private、excluded、hidden、root 外のコンテンツは
79
- サイドバーと前後ページリンクに出ません。
83
+ サイドバーと前後ページリンクに表示されません。
80
84
 
81
85
  ## エクスポート
82
86
 
83
- - `docs(options)` / `docsPlugin(options)`: プラグインファクトリ
87
+ - `docs(options)` / `docs(options)`: プラグインファクトリ
84
88
  - `buildDocsNavigation(entries, options)`: フレームワークに依存しないナビゲーションモデル
85
89
  - `flattenDocsNavigation(items)`: 前後ページリンク用の並び
86
90
  - `renderDocsSidebar(...)` / `renderDocsPrevNext(...)`: サーバー側の HTML レンダラー
package/dist/client.js CHANGED
@@ -1,10 +1,9 @@
1
1
  // src/docs-sidebar.client.ts
2
2
  var COLLAPSIBLE_PROPERTY = "--rb-docs-sidebar-collapsible";
3
- function initDocsSidebar() {
3
+ function initDocsSidebar(context = {}) {
4
+ const root = context.root ?? document;
4
5
  const details = Array.from(
5
- document.querySelectorAll(
6
- "[data-docs-sidebar-details]"
7
- )
6
+ root.querySelectorAll("[data-docs-sidebar-details]")
8
7
  );
9
8
  const first = details[0];
10
9
  if (!first) return;
@@ -22,6 +21,7 @@ function initDocsSidebar() {
22
21
  apply(next);
23
22
  };
24
23
  window.addEventListener("resize", sync, { passive: true });
24
+ return () => window.removeEventListener("resize", sync);
25
25
  }
26
26
  function isCollapsible(element) {
27
27
  return getComputedStyle(element).getPropertyValue(COLLAPSIBLE_PROPERTY).trim() !== "0";
@@ -3,6 +3,7 @@ export type DocsSidebarProps = {
3
3
  readonly items?: readonly DocsNavigationItem[];
4
4
  readonly currentPermalink?: string;
5
5
  readonly label?: string;
6
+ readonly placement?: "inline" | "article-rail";
6
7
  };
7
8
  declare const DocsSidebar: (props: Readonly<DocsSidebarProps>) => Promise<import("hono/utils/html").HtmlEscapedString>;
8
9
  export default DocsSidebar;
@@ -175,7 +175,7 @@ var DocsSidebar = (async (props) => {
175
175
  const label = props.label ?? options?.sidebar?.label ?? "Docs navigation";
176
176
  if (items.length === 0) return html``;
177
177
  const permalink = currentPermalink ?? "";
178
- return /* @__PURE__ */ jsxs("details", { class: "rb-docs-sidebar-details", "data-docs-sidebar-details": true, open: true, children: [
178
+ const sidebar = /* @__PURE__ */ jsxs("details", { class: "rb-docs-sidebar-details", "data-docs-sidebar-details": true, open: true, children: [
179
179
  /* @__PURE__ */ jsx("summary", { class: "rb-docs-sidebar-summary", children: label }),
180
180
  /* @__PURE__ */ jsx("nav", { class: "rb-docs-sidebar", "aria-label": label, "data-docs-sidebar": true, children: /* @__PURE__ */ jsx(
181
181
  DocsSidebarItems,
@@ -186,6 +186,7 @@ var DocsSidebar = (async (props) => {
186
186
  }
187
187
  ) })
188
188
  ] });
189
+ return props.placement === "article-rail" ? /* @__PURE__ */ jsx("aside", { class: "rb-docs-sidebar-rail", children: sidebar }) : sidebar;
189
190
  });
190
191
  function DocsSidebarItems({
191
192
  items,
package/dist/index.d.ts CHANGED
@@ -10,4 +10,3 @@ export { renderDocsPrevNext, renderDocsSidebar } from "./src/render.js";
10
10
  export type { DocsNavigationItem, DocsOptions, DocsSidebarFrontmatter, ResolvedDocsOptions, } from "./src/types.js";
11
11
  export declare const DOCS_PLUGIN_NAME = "docs";
12
12
  export declare function docs(options: DocsOptions): import("@riebeckite/core").RiebeckitePlugin<DocsOptions>;
13
- export declare const docsPlugin: typeof docs;
package/dist/index.js CHANGED
@@ -261,7 +261,7 @@ var DocsSidebar = (async (props) => {
261
261
  const label = props.label ?? options?.sidebar?.label ?? "Docs navigation";
262
262
  if (items.length === 0) return html2``;
263
263
  const permalink = currentPermalink ?? "";
264
- return /* @__PURE__ */ jsxs2("details", { class: "rb-docs-sidebar-details", "data-docs-sidebar-details": true, open: true, children: [
264
+ const sidebar = /* @__PURE__ */ jsxs2("details", { class: "rb-docs-sidebar-details", "data-docs-sidebar-details": true, open: true, children: [
265
265
  /* @__PURE__ */ jsx2("summary", { class: "rb-docs-sidebar-summary", children: label }),
266
266
  /* @__PURE__ */ jsx2("nav", { class: "rb-docs-sidebar", "aria-label": label, "data-docs-sidebar": true, children: /* @__PURE__ */ jsx2(
267
267
  DocsSidebarItems,
@@ -272,6 +272,7 @@ var DocsSidebar = (async (props) => {
272
272
  }
273
273
  ) })
274
274
  ] });
275
+ return props.placement === "article-rail" ? /* @__PURE__ */ jsx2("aside", { class: "rb-docs-sidebar-rail", children: sidebar }) : sidebar;
275
276
  });
276
277
  function DocsSidebarItems({
277
278
  items,
@@ -344,11 +345,10 @@ function findDocsOptions2(plugins) {
344
345
 
345
346
  // src/docs-sidebar.client.ts
346
347
  var COLLAPSIBLE_PROPERTY = "--rb-docs-sidebar-collapsible";
347
- function initDocsSidebar() {
348
+ function initDocsSidebar(context = {}) {
349
+ const root = context.root ?? document;
348
350
  const details = Array.from(
349
- document.querySelectorAll(
350
- "[data-docs-sidebar-details]"
351
- )
351
+ root.querySelectorAll("[data-docs-sidebar-details]")
352
352
  );
353
353
  const first = details[0];
354
354
  if (!first) return;
@@ -366,6 +366,7 @@ function initDocsSidebar() {
366
366
  apply(next);
367
367
  };
368
368
  window.addEventListener("resize", sync, { passive: true });
369
+ return () => window.removeEventListener("resize", sync);
369
370
  }
370
371
  function isCollapsible(element) {
371
372
  return getComputedStyle(element).getPropertyValue(COLLAPSIBLE_PROPERTY).trim() !== "0";
@@ -455,12 +456,14 @@ function docs(options) {
455
456
  createClientEntry(
456
457
  DOCS_PLUGIN_NAME,
457
458
  "@riebeckite/plugin-docs/client",
458
- "initDocsSidebar"
459
+ "initDocsSidebar",
460
+ void 0,
461
+ void 0,
462
+ "context"
459
463
  )
460
464
  ]
461
465
  });
462
466
  }
463
- var docsPlugin = docs;
464
467
  function validateDocsOptions(options) {
465
468
  const issues = [];
466
469
  if (!options || typeof options !== "object") {
@@ -483,7 +486,6 @@ export {
483
486
  docs_sidebar_default as DocsSidebar,
484
487
  buildDocsNavigation,
485
488
  docs,
486
- docsPlugin,
487
489
  flattenDocsNavigation,
488
490
  getDocsNavigation,
489
491
  getDocsPrevNext,
@@ -1 +1,5 @@
1
- export declare function initDocsSidebar(): void;
1
+ type ClientContext = {
2
+ root?: ParentNode;
3
+ };
4
+ export declare function initDocsSidebar(context?: ClientContext): () => void;
5
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-docs",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -27,13 +27,13 @@
27
27
  "./style.css": "./style.css"
28
28
  },
29
29
  "dependencies": {
30
- "hono": "^4.12.25",
31
- "@riebeckite/core": "0.0.31",
32
- "@riebeckite/ui": "0.0.31"
30
+ "@riebeckite/core": "0.0.33",
31
+ "@riebeckite/ui": "0.0.33",
32
+ "hono": "^4.12.25"
33
33
  },
34
34
  "devDependencies": {
35
- "tsx": "^4.22.4",
36
- "@riebeckite/test": "0.0.31"
35
+ "@riebeckite/test": "0.0.33",
36
+ "tsx": "^4.22.4"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
package/style.css CHANGED
@@ -2,6 +2,43 @@
2
2
  --rb-docs-sidebar-collapsible: 1;
3
3
  }
4
4
 
5
+ .rb-docs-sidebar-rail {
6
+ display: none;
7
+ }
8
+
9
+ @media (min-width: 48rem) {
10
+ .rb-docs-sidebar-rail {
11
+ display: block;
12
+ min-width: 0;
13
+ margin-block: var(--rb-space-4);
14
+ }
15
+ }
16
+
17
+ @media (min-width: 88rem) {
18
+ :is(:root, .rb-theme-root)[data-article-layout="article"]
19
+ .rb-docs-sidebar-rail {
20
+ display: block;
21
+ grid-column: 1;
22
+ grid-row: 1;
23
+ position: sticky;
24
+ top: var(--rb-docs-rail-top);
25
+ align-self: start;
26
+ width: var(--rb-layout-sidebar);
27
+ max-height: var(--rb-docs-rail-max-block-size);
28
+ margin-block: 0;
29
+ margin-inline-start: calc(
30
+ -1 *
31
+ var(--rb-layout-sidebar) -
32
+ var(--rb-layout-gap)
33
+ );
34
+ overflow: auto;
35
+ padding-block: 0;
36
+ padding-inline-end: 1rem;
37
+ border-inline-end: 1px solid
38
+ color-mix(in oklab, currentColor 18%, transparent);
39
+ }
40
+ }
41
+
5
42
  .rb-docs-sidebar-details > .rb-docs-sidebar-summary {
6
43
  cursor: pointer;
7
44
  font-size: 0.95rem;