@riebeckite/plugin-docs 0.0.27 → 0.0.29

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.
@@ -2,14 +2,8 @@
2
2
  import { useArticleContext, useSiteContext } from "@riebeckite/ui";
3
3
  import { html } from "hono/html";
4
4
 
5
- // index.ts
6
- import {
7
- createClientEntry,
8
- createStyleAsset,
9
- definePlugin
10
- } from "@riebeckite/core";
11
-
12
5
  // src/navigation.ts
6
+ import { escapeRegExp } from "@riebeckite/core";
13
7
  var ROOT_SEGMENT = "";
14
8
  function resolveDocsOptions(options) {
15
9
  return {
@@ -72,9 +66,6 @@ function stripFilenameLanguage(path, language) {
72
66
  );
73
67
  return segments.join("/");
74
68
  }
75
- function escapeRegExp(value) {
76
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
77
- }
78
69
  function readSidebarFrontmatter(value) {
79
70
  if (!value || typeof value !== "object" || Array.isArray(value)) return {};
80
71
  const record = value;
@@ -158,7 +149,7 @@ function titleFromSegment(segment) {
158
149
  return segment.replace(/[-_]+/g, " ").replace(/\b\p{L}/gu, (letter) => letter.toLocaleUpperCase("en"));
159
150
  }
160
151
 
161
- // index.ts
152
+ // src/data.ts
162
153
  var getDocsNavigation = ({ view, entrySlug, options }) => {
163
154
  const entry = view.findRoutableBySlug(entrySlug);
164
155
  if (!entry) return [];
package/dist/index.d.ts CHANGED
@@ -1,25 +1,13 @@
1
- import { type PluginDataHelper, type PublicContentView } from "@riebeckite/core";
2
- import type { DocsNavigationItem, DocsNavigationLink, DocsOptions } from "./src/types.js";
1
+ import type { DocsOptions } from "./src/types.js";
3
2
  export type { DocsPrevNextProps } from "./components/docs-prev-next.js";
4
3
  export { default as DocsPrevNext } from "./components/docs-prev-next.js";
5
4
  export type { DocsSidebarProps } from "./components/docs-sidebar.js";
6
5
  export { default as DocsSidebar } from "./components/docs-sidebar.js";
6
+ export { getDocsNavigation, getDocsPrevNext } from "./src/data.js";
7
7
  export { initDocsSidebar } from "./src/docs-sidebar.client.js";
8
8
  export { buildDocsNavigation, flattenDocsNavigation, resolveDocsOptions, } from "./src/navigation.js";
9
9
  export { renderDocsPrevNext, renderDocsSidebar } from "./src/render.js";
10
10
  export type { DocsNavigationItem, DocsOptions, DocsSidebarFrontmatter, ResolvedDocsOptions, } from "./src/types.js";
11
- export declare const getDocsNavigation: PluginDataHelper<{
12
- view: PublicContentView;
13
- entrySlug: string;
14
- options: DocsOptions;
15
- }, readonly DocsNavigationItem[]>;
16
- export declare const getDocsPrevNext: PluginDataHelper<{
17
- items: readonly DocsNavigationItem[];
18
- slug: string;
19
- }, {
20
- readonly previous?: DocsNavigationLink;
21
- readonly next?: DocsNavigationLink;
22
- }>;
23
11
  export declare const DOCS_PLUGIN_NAME = "docs";
24
12
  export declare function docs(options: DocsOptions): import("@riebeckite/core").RiebeckitePlugin<DocsOptions>;
25
13
  export declare const docsPlugin: typeof docs;
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  } from "@riebeckite/core";
7
7
 
8
8
  // src/navigation.ts
9
+ import { escapeRegExp } from "@riebeckite/core";
9
10
  var ROOT_SEGMENT = "";
10
11
  function resolveDocsOptions(options) {
11
12
  return {
@@ -74,9 +75,6 @@ function stripFilenameLanguage(path, language) {
74
75
  );
75
76
  return segments.join("/");
76
77
  }
77
- function escapeRegExp(value) {
78
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
79
- }
80
78
  function readSidebarFrontmatter(value) {
81
79
  if (!value || typeof value !== "object" || Array.isArray(value)) return {};
82
80
  const record = value;
@@ -163,6 +161,27 @@ function titleFromSegment(segment) {
163
161
  // components/docs-prev-next.tsx
164
162
  import { useArticleContext, useSiteContext } from "@riebeckite/ui";
165
163
  import { html } from "hono/html";
164
+
165
+ // src/data.ts
166
+ var getDocsNavigation = ({ view, entrySlug, options }) => {
167
+ const entry = view.findRoutableBySlug(entrySlug);
168
+ if (!entry) return [];
169
+ const localized = view.discoverableEntries.filter(
170
+ (candidate) => candidate.publicLocation.language === entry.publicLocation.language
171
+ );
172
+ return buildDocsNavigation(localized, resolveDocsOptions(options));
173
+ };
174
+ var getDocsPrevNext = ({ items, slug }) => {
175
+ const sequence = flattenDocsNavigation(items);
176
+ const index = sequence.findIndex((item) => item.slug === slug);
177
+ if (index < 0) return {};
178
+ return {
179
+ ...sequence[index - 1] ? { previous: sequence[index - 1] } : {},
180
+ ...sequence[index + 1] ? { next: sequence[index + 1] } : {}
181
+ };
182
+ };
183
+
184
+ // components/docs-prev-next.tsx
166
185
  import { jsx, jsxs } from "hono/jsx/jsx-runtime";
167
186
  var DocsPrevNext = (async (props) => {
168
187
  const site = useSiteContext();
@@ -418,23 +437,6 @@ function escapeAttribute(value) {
418
437
  }
419
438
 
420
439
  // index.ts
421
- var getDocsNavigation = ({ view, entrySlug, options }) => {
422
- const entry = view.findRoutableBySlug(entrySlug);
423
- if (!entry) return [];
424
- const localized = view.discoverableEntries.filter(
425
- (candidate) => candidate.publicLocation.language === entry.publicLocation.language
426
- );
427
- return buildDocsNavigation(localized, resolveDocsOptions(options));
428
- };
429
- var getDocsPrevNext = ({ items, slug }) => {
430
- const sequence = flattenDocsNavigation(items);
431
- const index = sequence.findIndex((item) => item.slug === slug);
432
- if (index < 0) return {};
433
- return {
434
- ...sequence[index - 1] ? { previous: sequence[index - 1] } : {},
435
- ...sequence[index + 1] ? { next: sequence[index + 1] } : {}
436
- };
437
- };
438
440
  var DOCS_PLUGIN_NAME = "docs";
439
441
  function docs(options) {
440
442
  const resolved = resolveDocsOptions(options);
@@ -0,0 +1,14 @@
1
+ import type { PluginDataHelper, PublicContentView } from "@riebeckite/core";
2
+ import type { DocsNavigationItem, DocsNavigationLink, DocsOptions } from "./types.js";
3
+ export declare const getDocsNavigation: PluginDataHelper<{
4
+ view: PublicContentView;
5
+ entrySlug: string;
6
+ options: DocsOptions;
7
+ }, readonly DocsNavigationItem[]>;
8
+ export declare const getDocsPrevNext: PluginDataHelper<{
9
+ items: readonly DocsNavigationItem[];
10
+ slug: string;
11
+ }, {
12
+ readonly previous?: DocsNavigationLink;
13
+ readonly next?: DocsNavigationLink;
14
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-docs",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,12 +28,12 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "hono": "^4.12.25",
31
- "@riebeckite/ui": "0.0.27",
32
- "@riebeckite/core": "0.0.27"
31
+ "@riebeckite/core": "0.0.29",
32
+ "@riebeckite/ui": "0.0.29"
33
33
  },
34
34
  "devDependencies": {
35
35
  "tsx": "^4.22.4",
36
- "@riebeckite/test": "0.0.27"
36
+ "@riebeckite/test": "0.0.29"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"