@riebeckite/plugin-docs 0.0.23 → 0.0.24
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 +6 -0
- package/README_ja.md +3 -3
- package/dist/components/docs-sidebar.js +72 -21
- package/dist/index.js +75 -24
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -67,6 +67,12 @@ fields you want to override and leave the rest of the vault untouched.
|
|
|
67
67
|
|
|
68
68
|
The plugin provides React-like JSX components for site integration:
|
|
69
69
|
|
|
70
|
+
- `<DocsSidebar items={...} currentPermalink? label? />` renders
|
|
71
|
+
`details.rb-docs-sidebar-details` with `nav.rb-docs-sidebar`
|
|
72
|
+
- `<DocsPrevNext previous? next? />` renders `nav.rb-docs-prev-next`
|
|
73
|
+
|
|
74
|
+
The `initDocsSidebar` client keeps the sidebar collapsible.
|
|
75
|
+
|
|
70
76
|
## l10n and publishing
|
|
71
77
|
|
|
72
78
|
When localization metadata from `@riebeckite/plugin-l10n` is present, each page
|
package/README_ja.md
CHANGED
|
@@ -64,10 +64,10 @@ sidebar:
|
|
|
64
64
|
|
|
65
65
|
Plugin は React ライクな JSX コンポーネントをサイト統合に提供します。
|
|
66
66
|
|
|
67
|
-
- `<DocsSidebar items={...} currentPermalink? label? />` は `nav.
|
|
68
|
-
- `<DocsPrevNext previous? next? />` は `nav.
|
|
67
|
+
- `<DocsSidebar items={...} currentPermalink? label? />` は `details.rb-docs-sidebar-details` と `nav.rb-docs-sidebar` を描画
|
|
68
|
+
- `<DocsPrevNext previous? next? />` は `nav.rb-docs-prev-next` を描画
|
|
69
69
|
|
|
70
|
-
クライアント `initDocsSidebar`
|
|
70
|
+
クライアント `initDocsSidebar` がサイドバーを畳めるようにします。
|
|
71
71
|
|
|
72
72
|
## l10n と公開の境界
|
|
73
73
|
|
|
@@ -6,31 +6,82 @@ var DocsSidebar = (({
|
|
|
6
6
|
label = "Docs navigation"
|
|
7
7
|
}) => {
|
|
8
8
|
if (items.length === 0) return null;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
const permalink = currentPermalink ?? "";
|
|
10
|
+
return /* @__PURE__ */ jsxs("details", { class: "rb-docs-sidebar-details", "data-docs-sidebar-details": true, open: true, children: [
|
|
11
|
+
/* @__PURE__ */ jsx("summary", { class: "rb-docs-sidebar-summary", children: label }),
|
|
12
|
+
/* @__PURE__ */ jsx("nav", { class: "rb-docs-sidebar", "aria-label": label, "data-docs-sidebar": true, children: /* @__PURE__ */ jsx(
|
|
13
|
+
DocsSidebarItems,
|
|
14
|
+
{
|
|
15
|
+
items,
|
|
16
|
+
currentPermalink: permalink,
|
|
17
|
+
level: 1
|
|
18
|
+
}
|
|
19
|
+
) })
|
|
20
|
+
] });
|
|
17
21
|
});
|
|
22
|
+
function DocsSidebarItems({
|
|
23
|
+
items,
|
|
24
|
+
currentPermalink,
|
|
25
|
+
level
|
|
26
|
+
}) {
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
"ul",
|
|
29
|
+
{
|
|
30
|
+
class: `rb-docs-sidebar__list rb-docs-sidebar__list--level-${level}`,
|
|
31
|
+
"data-docs-level": String(level),
|
|
32
|
+
children: items.map((item) => /* @__PURE__ */ jsx(
|
|
33
|
+
DocsSidebarItem,
|
|
34
|
+
{
|
|
35
|
+
item,
|
|
36
|
+
currentPermalink,
|
|
37
|
+
level
|
|
38
|
+
},
|
|
39
|
+
item.slug ?? item.title
|
|
40
|
+
))
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
18
44
|
function DocsSidebarItem({
|
|
19
45
|
item,
|
|
20
|
-
currentPermalink
|
|
46
|
+
currentPermalink,
|
|
47
|
+
level
|
|
21
48
|
}) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
const isCurrent = item.href === currentPermalink;
|
|
50
|
+
const isCurrentBranch = item.children.some(
|
|
51
|
+
(child) => containsPermalink(child, currentPermalink)
|
|
52
|
+
);
|
|
53
|
+
const collapsed = item.collapsed === true && !isCurrent && !isCurrentBranch;
|
|
54
|
+
return /* @__PURE__ */ jsxs(
|
|
55
|
+
"li",
|
|
56
|
+
{
|
|
57
|
+
class: `rb-docs-sidebar__item rb-docs-sidebar__item--level-${level}`,
|
|
58
|
+
"data-docs-level": String(level),
|
|
59
|
+
"data-docs-collapsed": item.children.length > 0 ? String(collapsed) : void 0,
|
|
60
|
+
children: [
|
|
61
|
+
item.href ? /* @__PURE__ */ jsx(
|
|
62
|
+
"a",
|
|
63
|
+
{
|
|
64
|
+
class: "rb-docs-sidebar__link",
|
|
65
|
+
href: item.href,
|
|
66
|
+
"data-docs-link": true,
|
|
67
|
+
"aria-current": isCurrent ? "page" : void 0,
|
|
68
|
+
children: item.title
|
|
69
|
+
}
|
|
70
|
+
) : /* @__PURE__ */ jsx("span", { class: "rb-docs-sidebar__section", "data-docs-section": true, children: item.title }),
|
|
71
|
+
item.children.length > 0 ? /* @__PURE__ */ jsx(
|
|
72
|
+
DocsSidebarItems,
|
|
73
|
+
{
|
|
74
|
+
items: item.children,
|
|
75
|
+
currentPermalink,
|
|
76
|
+
level: level + 1
|
|
77
|
+
}
|
|
78
|
+
) : null
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
function containsPermalink(item, currentPermalink) {
|
|
84
|
+
return item.href === currentPermalink || item.children.some((child) => containsPermalink(child, currentPermalink));
|
|
34
85
|
}
|
|
35
86
|
var docs_sidebar_default = DocsSidebar;
|
|
36
87
|
export {
|
package/dist/index.js
CHANGED
|
@@ -218,31 +218,82 @@ var DocsSidebar = (({
|
|
|
218
218
|
label = "Docs navigation"
|
|
219
219
|
}) => {
|
|
220
220
|
if (items.length === 0) return null;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
{
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
221
|
+
const permalink = currentPermalink ?? "";
|
|
222
|
+
return /* @__PURE__ */ jsxs2("details", { class: "rb-docs-sidebar-details", "data-docs-sidebar-details": true, open: true, children: [
|
|
223
|
+
/* @__PURE__ */ jsx2("summary", { class: "rb-docs-sidebar-summary", children: label }),
|
|
224
|
+
/* @__PURE__ */ jsx2("nav", { class: "rb-docs-sidebar", "aria-label": label, "data-docs-sidebar": true, children: /* @__PURE__ */ jsx2(
|
|
225
|
+
DocsSidebarItems,
|
|
226
|
+
{
|
|
227
|
+
items,
|
|
228
|
+
currentPermalink: permalink,
|
|
229
|
+
level: 1
|
|
230
|
+
}
|
|
231
|
+
) })
|
|
232
|
+
] });
|
|
229
233
|
});
|
|
234
|
+
function DocsSidebarItems({
|
|
235
|
+
items,
|
|
236
|
+
currentPermalink,
|
|
237
|
+
level
|
|
238
|
+
}) {
|
|
239
|
+
return /* @__PURE__ */ jsx2(
|
|
240
|
+
"ul",
|
|
241
|
+
{
|
|
242
|
+
class: `rb-docs-sidebar__list rb-docs-sidebar__list--level-${level}`,
|
|
243
|
+
"data-docs-level": String(level),
|
|
244
|
+
children: items.map((item) => /* @__PURE__ */ jsx2(
|
|
245
|
+
DocsSidebarItem,
|
|
246
|
+
{
|
|
247
|
+
item,
|
|
248
|
+
currentPermalink,
|
|
249
|
+
level
|
|
250
|
+
},
|
|
251
|
+
item.slug ?? item.title
|
|
252
|
+
))
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
230
256
|
function DocsSidebarItem({
|
|
231
257
|
item,
|
|
232
|
-
currentPermalink
|
|
258
|
+
currentPermalink,
|
|
259
|
+
level
|
|
233
260
|
}) {
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
261
|
+
const isCurrent = item.href === currentPermalink;
|
|
262
|
+
const isCurrentBranch = item.children.some(
|
|
263
|
+
(child) => containsPermalink(child, currentPermalink)
|
|
264
|
+
);
|
|
265
|
+
const collapsed = item.collapsed === true && !isCurrent && !isCurrentBranch;
|
|
266
|
+
return /* @__PURE__ */ jsxs2(
|
|
267
|
+
"li",
|
|
268
|
+
{
|
|
269
|
+
class: `rb-docs-sidebar__item rb-docs-sidebar__item--level-${level}`,
|
|
270
|
+
"data-docs-level": String(level),
|
|
271
|
+
"data-docs-collapsed": item.children.length > 0 ? String(collapsed) : void 0,
|
|
272
|
+
children: [
|
|
273
|
+
item.href ? /* @__PURE__ */ jsx2(
|
|
274
|
+
"a",
|
|
275
|
+
{
|
|
276
|
+
class: "rb-docs-sidebar__link",
|
|
277
|
+
href: item.href,
|
|
278
|
+
"data-docs-link": true,
|
|
279
|
+
"aria-current": isCurrent ? "page" : void 0,
|
|
280
|
+
children: item.title
|
|
281
|
+
}
|
|
282
|
+
) : /* @__PURE__ */ jsx2("span", { class: "rb-docs-sidebar__section", "data-docs-section": true, children: item.title }),
|
|
283
|
+
item.children.length > 0 ? /* @__PURE__ */ jsx2(
|
|
284
|
+
DocsSidebarItems,
|
|
285
|
+
{
|
|
286
|
+
items: item.children,
|
|
287
|
+
currentPermalink,
|
|
288
|
+
level: level + 1
|
|
289
|
+
}
|
|
290
|
+
) : null
|
|
291
|
+
]
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
function containsPermalink(item, currentPermalink) {
|
|
296
|
+
return item.href === currentPermalink || item.children.some((child) => containsPermalink(child, currentPermalink));
|
|
246
297
|
}
|
|
247
298
|
var docs_sidebar_default = DocsSidebar;
|
|
248
299
|
|
|
@@ -296,15 +347,15 @@ function renderItems(items, currentPermalink, level) {
|
|
|
296
347
|
function renderItem(item, currentPermalink, level) {
|
|
297
348
|
const isCurrent = item.href === currentPermalink;
|
|
298
349
|
const isCurrentBranch = item.children.some(
|
|
299
|
-
(child) =>
|
|
350
|
+
(child) => containsPermalink2(child, currentPermalink)
|
|
300
351
|
);
|
|
301
352
|
const children = item.children.length > 0 ? renderItems(item.children, currentPermalink, level + 1) : "";
|
|
302
353
|
const collapsed = item.collapsed === true && !isCurrent && !isCurrentBranch;
|
|
303
354
|
const state = item.children.length > 0 ? ` data-docs-collapsed="${collapsed ? "true" : "false"}"` : "";
|
|
304
355
|
return `<li class="rb-docs-sidebar__item rb-docs-sidebar__item--level-${level}" data-docs-level="${level}"${state}>${renderItemLabel(item, isCurrent)}${children}</li>`;
|
|
305
356
|
}
|
|
306
|
-
function
|
|
307
|
-
return item.href === currentPermalink || item.children.some((child) =>
|
|
357
|
+
function containsPermalink2(item, currentPermalink) {
|
|
358
|
+
return item.href === currentPermalink || item.children.some((child) => containsPermalink2(child, currentPermalink));
|
|
308
359
|
}
|
|
309
360
|
function renderItemLabel(item, isCurrent) {
|
|
310
361
|
const current = isCurrent ? ' aria-current="page"' : "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-docs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"hono": "^4.12.25",
|
|
31
|
-
"@riebeckite/core": "0.0.
|
|
31
|
+
"@riebeckite/core": "0.0.24"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"tsx": "^4.22.4",
|
|
35
|
-
"@riebeckite/test": "0.0.
|
|
35
|
+
"@riebeckite/test": "0.0.24"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|