@vendure-io/docs-provider 0.3.0 → 0.5.0

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
@@ -23,7 +23,69 @@ bun add @vendure-io/docs-provider
23
23
 
24
24
  ### Defining a Documentation Package Manifest
25
25
 
26
- Documentation packages export a manifest that describes their structure. **Important**: File paths must be absolute paths. Use a helper pattern to resolve paths relative to your package root:
26
+ Documentation packages export a manifest that describes their structure. **Important**: File paths must be absolute paths. Use a helper pattern to resolve paths relative to your package root.
27
+
28
+ #### Quick Start (Minimal Config)
29
+
30
+ ```typescript
31
+ import { resolveManifest, type DocsPackageManifestInput } from '@vendure-io/docs-provider'
32
+ import { dirname, join } from 'path'
33
+ import { fileURLToPath } from 'url'
34
+
35
+ const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)))
36
+ const file = (relativePath: string) => join(packageRoot, relativePath)
37
+
38
+ // Minimal: title/slug auto-derived from files
39
+ const manifestInput: DocsPackageManifestInput = {
40
+ id: 'my-plugin',
41
+ name: 'My Plugin',
42
+ version: '1.0.0',
43
+ vendureVersion: 'v3',
44
+ basePath: packageRoot,
45
+ navigation: [
46
+ { file: file('docs/getting-started.mdx') },
47
+ { file: file('docs/installation.mdx') },
48
+ { file: file('docs/configuration.mdx') },
49
+ ],
50
+ }
51
+
52
+ export const manifest = resolveManifest(manifestInput)
53
+ ```
54
+
55
+ #### Using Folder Discovery
56
+
57
+ ```typescript
58
+ import {
59
+ createNavigationFromFolder,
60
+ resolveManifest,
61
+ type DocsPackageManifestInput,
62
+ } from '@vendure-io/docs-provider'
63
+ import { dirname, join } from 'path'
64
+ import { fileURLToPath } from 'url'
65
+
66
+ const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)))
67
+ const file = (relativePath: string) => join(packageRoot, relativePath)
68
+
69
+ const manifestInput: DocsPackageManifestInput = {
70
+ id: 'my-plugin',
71
+ name: 'My Plugin',
72
+ version: '1.0.0',
73
+ vendureVersion: 'v3',
74
+ basePath: packageRoot,
75
+ navigation: [
76
+ { file: file('docs/getting-started.mdx') },
77
+ {
78
+ title: 'Guides',
79
+ slug: 'guides',
80
+ children: createNavigationFromFolder(join(packageRoot, 'docs/guides')),
81
+ },
82
+ ],
83
+ }
84
+
85
+ export const manifest = resolveManifest(manifestInput)
86
+ ```
87
+
88
+ #### Explicit Navigation (Full Control)
27
89
 
28
90
  ```typescript
29
91
  import type { DocsPackageManifest } from '@vendure-io/docs-provider'
@@ -129,6 +191,43 @@ const pages = getLeafNodes(manifest)
129
191
  const { prev, next } = getPrevNextNodes(manifest, 'getting-started/installation')
130
192
  ```
131
193
 
194
+ ### Hidden Pages
195
+
196
+ You can hide pages from the sidebar navigation while keeping them accessible via direct URL:
197
+
198
+ ```typescript
199
+ const manifest: DocsPackageManifest = {
200
+ // ...
201
+ navigation: [
202
+ {
203
+ title: 'Public Page',
204
+ slug: 'public',
205
+ file: file('docs/public.mdx'),
206
+ },
207
+ {
208
+ title: 'Hidden Page',
209
+ slug: 'hidden',
210
+ file: file('docs/hidden.mdx'),
211
+ hidden: true, // Won't appear in sidebar, but /docs/hidden still works
212
+ },
213
+ ],
214
+ }
215
+ ```
216
+
217
+ ### Browser Entry Point
218
+
219
+ For client-side React components (with `'use client'`), use the `/browser` entry point to avoid bundling Node.js modules:
220
+
221
+ ```typescript
222
+ // In client components
223
+ import { filterVisibleNavigation, type NavigationNode } from '@vendure-io/docs-provider/browser'
224
+
225
+ // Filter hidden pages before rendering sidebar
226
+ const visibleNavigation = filterVisibleNavigation(manifest.navigation)
227
+ ```
228
+
229
+ The main entry point includes Node.js-only utilities (`resolveManifest`, `createNavigationFromFolder`) that require `fs` access and cannot be used in browser contexts.
230
+
132
231
  ### Parsing MDX Frontmatter
133
232
 
134
233
  ```typescript
@@ -158,19 +257,22 @@ if (hasFrontmatter(mdxContent)) {
158
257
 
159
258
  ### Types
160
259
 
161
- | Type | Description |
162
- | --------------------- | ----------------------------------------------------- |
163
- | `DocsPackageManifest` | Main manifest describing a documentation package |
164
- | `NavigationNode` | A node in the navigation tree |
165
- | `DocPage` | A loaded documentation page with metadata and content |
166
- | `DocPageMeta` | Frontmatter metadata for a page |
167
- | `ParsedFrontmatter` | Result of parsing frontmatter (meta + content) |
168
- | `SearchConfig` | Search indexing configuration |
169
- | `VendureVersion` | Supported Vendure versions (`'v1' \| 'v2' \| 'v3'`) |
170
- | `FlatNavigationNode` | Flattened navigation node with path info |
171
- | `BreadcrumbItem` | Breadcrumb navigation item |
172
- | `LoadedDocsPackage` | Result of loading a docs package |
173
- | `GitHubConfig` | GitHub repository configuration for edit links |
260
+ | Type | Description |
261
+ | -------------------------- | ------------------------------------------------------ |
262
+ | `DocsPackageManifest` | Main manifest describing a documentation package |
263
+ | `DocsPackageManifestInput` | Manifest input with optional title/slug in navigation |
264
+ | `NavigationNode` | A node in the navigation tree |
265
+ | `NavigationNodeInput` | Navigation node input with optional title/slug |
266
+ | `DocPage` | A loaded documentation page with metadata and content |
267
+ | `DocPageMeta` | Frontmatter metadata for a page |
268
+ | `ParsedFrontmatter` | Result of parsing frontmatter (meta + content) |
269
+ | `SearchConfig` | Search indexing configuration |
270
+ | `VendureVersion` | Supported Vendure versions (`'v1' \| 'v2' \| 'v3'`) |
271
+ | `FlatNavigationNode` | Flattened navigation node with path info |
272
+ | `BreadcrumbItem` | Breadcrumb navigation item |
273
+ | `LoadedDocsPackage` | Result of loading a docs package |
274
+ | `GitHubConfig` | GitHub repository configuration for edit links |
275
+ | `FileInfo` | Information about a discovered file (for folder utils) |
174
276
 
175
277
  ### MDX Component Props
176
278
 
@@ -181,6 +283,7 @@ if (hasFrontmatter(mdxContent)) {
181
283
  | `MemberDescriptionProps` | Props for MemberDescription component |
182
284
  | `CustomFieldPropertyProps` | Props for CustomFieldProperty component |
183
285
  | `StackblitzProps` | Props for Stackblitz component |
286
+ | `DocsLinkProps` | Props for DocsLink component |
184
287
  | `MdxComponentProps` | Union type of all MDX component props |
185
288
 
186
289
  ### Schemas (Zod)
@@ -188,7 +291,9 @@ if (hasFrontmatter(mdxContent)) {
188
291
  All types have corresponding Zod schemas for runtime validation:
189
292
 
190
293
  - `DocsPackageManifestSchema`
294
+ - `DocsPackageManifestInputSchema`
191
295
  - `NavigationNodeSchema`
296
+ - `NavigationNodeInputSchema`
192
297
  - `DocPageSchema`
193
298
  - `DocPageMetaSchema`
194
299
  - `SearchConfigSchema`
@@ -205,6 +310,8 @@ All types have corresponding Zod schemas for runtime validation:
205
310
  | Function | Description |
206
311
  | ---------------------------------------- | ----------------------------------------- |
207
312
  | `validateManifest(data)` | Validate raw data against manifest schema |
313
+ | `resolveManifest(input, options?)` | Resolve manifest input to full manifest |
314
+ | `manifestNeedsResolution(input)` | Check if manifest input needs resolution |
208
315
  | `findNavigationNode(manifest, slugPath)` | Find a node by slug path |
209
316
  | `flattenNavigation(manifest)` | Flatten navigation tree to array |
210
317
  | `buildBreadcrumbs(manifest, slugPath)` | Build breadcrumb trail |
@@ -215,9 +322,20 @@ All types have corresponding Zod schemas for runtime validation:
215
322
 
216
323
  #### Navigation Utilities
217
324
 
218
- | Function | Description |
219
- | --------------------------- | -------------------------------- |
220
- | `getAllFilePaths(manifest)` | Get all file paths from manifest |
325
+ | Function | Description |
326
+ | ----------------------------------------------- | --------------------------------------- |
327
+ | `getAllFilePaths(manifest)` | Get all file paths from manifest |
328
+ | `filterVisibleNavigation(nodes)` | Filter out hidden nodes from navigation |
329
+ | `createNavigationFromFolder(path, options?)` | Create navigation from folder contents |
330
+ | `createNestedNavigationFromFolder(path, opts?)` | Create nested navigation from folders |
331
+
332
+ #### Slug Utilities
333
+
334
+ | Function | Description |
335
+ | ------------------------- | ------------------------------- |
336
+ | `toSlug(text)` | Convert text to kebab-case slug |
337
+ | `slugFromFilename(file)` | Extract slug from filename |
338
+ | `titleFromFilename(file)` | Generate title from filename |
221
339
 
222
340
  #### Frontmatter Utilities
223
341
 
@@ -233,6 +351,7 @@ All types have corresponding Zod schemas for runtime validation:
233
351
  | Class | Description |
234
352
  | ------------------------- | ------------------------------------- |
235
353
  | `ManifestValidationError` | Thrown when manifest validation fails |
354
+ | `ManifestResolutionError` | Thrown when manifest resolution fails |
236
355
  | `FrontmatterParseError` | Thrown when frontmatter parsing fails |
237
356
 
238
357
  ## Development
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./manifest-D8kEDc9X.cjs"),a=require("./slug-utils-DUQgikEz.cjs");exports.BreadcrumbItemSchema=e.BreadcrumbItemSchema;exports.DocPageMetaSchema=e.DocPageMetaSchema;exports.DocPageSchema=e.DocPageSchema;exports.DocsPackageManifestInputSchema=e.DocsPackageManifestInputSchema;exports.DocsPackageManifestSchema=e.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=e.FlatNavigationNodeSchema;exports.GitHubConfigSchema=e.GitHubConfigSchema;exports.LoadedDocsPackageSchema=e.LoadedDocsPackageSchema;exports.ManifestValidationError=e.ManifestValidationError;exports.NavigationNodeInputSchema=e.NavigationNodeInputSchema;exports.NavigationNodeSchema=e.NavigationNodeSchema;exports.SearchConfigSchema=e.SearchConfigSchema;exports.VendureVersionSchema=e.VendureVersionSchema;exports.buildBreadcrumbs=e.buildBreadcrumbs;exports.findNavigationNode=e.findNavigationNode;exports.flattenNavigation=e.flattenNavigation;exports.getLeafNodes=e.getLeafNodes;exports.getNodesAtDepth=e.getNodesAtDepth;exports.getPrevNextNodes=e.getPrevNextNodes;exports.isNodeActive=e.isNodeActive;exports.validateManifest=e.validateManifest;exports.filterVisibleNavigation=a.filterVisibleNavigation;exports.getAllFilePaths=a.getAllFilePaths;exports.slugFromFilename=a.slugFromFilename;exports.titleFromFilename=a.titleFromFilename;exports.toSlug=a.toSlug;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Browser-safe exports from docs-provider.
3
+ * These utilities can be safely used in client components without bundling Node.js modules.
4
+ */
5
+ export type { BreadcrumbItem, DocPage, DocPageMeta, DocsPackageManifest, DocsPackageManifestInput, FlatNavigationNode, GitHubConfig, LoadedDocsPackage, NavigationNode, NavigationNodeInput, SearchConfig, VendureVersion, } from './types';
6
+ export { BreadcrumbItemSchema, DocPageMetaSchema, DocPageSchema, DocsPackageManifestInputSchema, DocsPackageManifestSchema, FlatNavigationNodeSchema, GitHubConfigSchema, LoadedDocsPackageSchema, NavigationNodeInputSchema, NavigationNodeSchema, SearchConfigSchema, VendureVersionSchema, } from './schema';
7
+ export { ManifestValidationError, buildBreadcrumbs, findNavigationNode, flattenNavigation, getLeafNodes, getNodesAtDepth, getPrevNextNodes, isNodeActive, validateManifest, } from './manifest';
8
+ export { filterVisibleNavigation, getAllFilePaths } from './navigation-utils';
9
+ export { slugFromFilename, titleFromFilename, toSlug } from './slug-utils';
10
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,8BAA8B,EAC9B,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAG7E,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,30 @@
1
+ import { B as s, D as t, a as i, b as o, c, F as g, G as m, L as n, M as d, N as r, d as h, S as N, V as l, e as S, f, g as v, h as u, i as D, j as F, k as P, v as b } from "./manifest-B_cvT6F9.js";
2
+ import { f as p, g as V, s as k, t as x, a as A } from "./slug-utils-DVKYe9h8.js";
3
+ export {
4
+ s as BreadcrumbItemSchema,
5
+ t as DocPageMetaSchema,
6
+ i as DocPageSchema,
7
+ o as DocsPackageManifestInputSchema,
8
+ c as DocsPackageManifestSchema,
9
+ g as FlatNavigationNodeSchema,
10
+ m as GitHubConfigSchema,
11
+ n as LoadedDocsPackageSchema,
12
+ d as ManifestValidationError,
13
+ r as NavigationNodeInputSchema,
14
+ h as NavigationNodeSchema,
15
+ N as SearchConfigSchema,
16
+ l as VendureVersionSchema,
17
+ S as buildBreadcrumbs,
18
+ p as filterVisibleNavigation,
19
+ f as findNavigationNode,
20
+ v as flattenNavigation,
21
+ V as getAllFilePaths,
22
+ u as getLeafNodes,
23
+ D as getNodesAtDepth,
24
+ F as getPrevNextNodes,
25
+ P as isNodeActive,
26
+ k as slugFromFilename,
27
+ x as titleFromFilename,
28
+ A as toSlug,
29
+ b as validateManifest
30
+ };
@@ -0,0 +1,136 @@
1
+ import { NavigationNodeInput } from './types';
2
+ /**
3
+ * Information about a discovered file for sorting and filtering
4
+ */
5
+ export interface FileInfo {
6
+ /** Absolute path to the file */
7
+ path: string;
8
+ /** Filename without path */
9
+ filename: string;
10
+ /** File extension (e.g., '.mdx') */
11
+ extension: string;
12
+ /** Parsed frontmatter data (may be empty if no frontmatter) */
13
+ frontmatter: Record<string, unknown>;
14
+ /** Order number from frontmatter (defaults to Infinity for sorting) */
15
+ order: number;
16
+ /** Title from frontmatter or derived from filename */
17
+ title: string;
18
+ /** Slug derived from filename */
19
+ slug: string;
20
+ }
21
+ /**
22
+ * Options for createNavigationFromFolder
23
+ */
24
+ export interface CreateNavigationFromFolderOptions {
25
+ /**
26
+ * File extensions to include
27
+ * @default ['.mdx', '.md']
28
+ */
29
+ extensions?: string[];
30
+ /**
31
+ * Filter function to exclude files
32
+ * Return false to exclude a file
33
+ * @default undefined (include all files)
34
+ */
35
+ filter?: (info: FileInfo) => boolean;
36
+ /**
37
+ * Sort function for ordering files
38
+ * @default Sort by frontmatter `order`, then alphabetically by title
39
+ */
40
+ sort?: (a: FileInfo, b: FileInfo) => number;
41
+ }
42
+ /**
43
+ * Options for createNestedNavigationFromFolder
44
+ */
45
+ export interface CreateNestedNavigationFromFolderOptions extends CreateNavigationFromFolderOptions {
46
+ /**
47
+ * Maximum depth to recurse into subfolders
48
+ * @default Infinity (no limit)
49
+ */
50
+ maxDepth?: number;
51
+ /**
52
+ * Filter function to exclude folders
53
+ * Return false to exclude a folder
54
+ * @default undefined (include all folders)
55
+ */
56
+ folderFilter?: (folderName: string, folderPath: string) => boolean;
57
+ }
58
+ /**
59
+ * Create navigation nodes by discovering MDX files in a folder.
60
+ *
61
+ * This function scans a folder for MDX/MD files and creates navigation nodes
62
+ * with titles and slugs automatically derived from frontmatter and filenames.
63
+ *
64
+ * @param folderPath - Absolute path to the folder to scan
65
+ * @param options - Discovery and sorting options
66
+ * @returns Array of NavigationNodeInput objects
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * // Basic usage - scan a folder
71
+ * const guides = createNavigationFromFolder(join(packageRoot, 'docs/guides'))
72
+ *
73
+ * // With filtering
74
+ * const guides = createNavigationFromFolder(join(packageRoot, 'docs/guides'), {
75
+ * filter: (info) => info.frontmatter.hidden !== true,
76
+ * })
77
+ *
78
+ * // Custom sorting
79
+ * const guides = createNavigationFromFolder(join(packageRoot, 'docs/guides'), {
80
+ * sort: (a, b) => a.filename.localeCompare(b.filename),
81
+ * })
82
+ * ```
83
+ */
84
+ export declare function createNavigationFromFolder(folderPath: string, options?: CreateNavigationFromFolderOptions): NavigationNodeInput[];
85
+ /**
86
+ * Create nested navigation by recursively scanning a folder and its subfolders.
87
+ *
88
+ * Each subfolder becomes a navigation section, and files within become pages.
89
+ * The folder structure is preserved in the navigation hierarchy.
90
+ *
91
+ * @param folderPath - Absolute path to the folder to scan
92
+ * @param options - Discovery, sorting, and recursion options
93
+ * @returns Array of NavigationNodeInput objects with nested children
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * // Given folder structure:
98
+ * // docs/
99
+ * // getting-started/
100
+ * // introduction.mdx
101
+ * // installation.mdx
102
+ * // guides/
103
+ * // basic-usage.mdx
104
+ * // advanced/
105
+ * // custom-plugins.mdx
106
+ *
107
+ * const nav = createNestedNavigationFromFolder(join(packageRoot, 'docs'))
108
+ * // Returns:
109
+ * // [
110
+ * // {
111
+ * // title: 'Getting Started',
112
+ * // slug: 'getting-started',
113
+ * // children: [
114
+ * // { title: 'Introduction', slug: 'introduction', file: '...' },
115
+ * // { title: 'Installation', slug: 'installation', file: '...' },
116
+ * // ],
117
+ * // },
118
+ * // {
119
+ * // title: 'Guides',
120
+ * // slug: 'guides',
121
+ * // children: [
122
+ * // { title: 'Basic Usage', slug: 'basic-usage', file: '...' },
123
+ * // {
124
+ * // title: 'Advanced',
125
+ * // slug: 'advanced',
126
+ * // children: [
127
+ * // { title: 'Custom Plugins', slug: 'custom-plugins', file: '...' },
128
+ * // ],
129
+ * // },
130
+ * // ],
131
+ * // },
132
+ * // ]
133
+ * ```
134
+ */
135
+ export declare function createNestedNavigationFromFolder(folderPath: string, options?: CreateNestedNavigationFromFolderOptions): NavigationNodeInput[];
136
+ //# sourceMappingURL=folder-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder-utils.d.ts","sourceRoot":"","sources":["../src/folder-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAA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[t] = r;
3
+ var o = (a, t, r) => m(a, typeof t != "symbol" ? t + "" : t, r);
4
+ import i from "gray-matter";
5
+ import { D as u } from "./manifest-B_cvT6F9.js";
6
+ class s extends Error {
7
+ constructor(r, e, n) {
8
+ super(r);
9
+ o(this, "filePath");
10
+ o(this, "originalError");
11
+ this.name = "FrontmatterParseError", this.filePath = e, this.originalError = n;
12
+ }
13
+ }
14
+ function F(a, t) {
15
+ try {
16
+ const { data: r, content: e } = i(a);
17
+ return {
18
+ meta: d(r, t),
19
+ content: e.trim()
20
+ };
21
+ } catch (r) {
22
+ throw r instanceof s ? r : new s(
23
+ `Failed to parse frontmatter${t ? ` in ${t}` : ""}`,
24
+ t,
25
+ r
26
+ );
27
+ }
28
+ }
29
+ function d(a, t) {
30
+ const r = u.safeParse(a);
31
+ if (!r.success) {
32
+ const e = r.error.issues.map((n) => ` - ${n.path.join(".")}: ${n.message}`).join(`
33
+ `);
34
+ throw new s(
35
+ `Invalid frontmatter${t ? ` in ${t}` : ""}:
36
+ ${e}`,
37
+ t,
38
+ r.error
39
+ );
40
+ }
41
+ return r.data;
42
+ }
43
+ function $(a) {
44
+ return a.trimStart().startsWith("---");
45
+ }
46
+ function l(a) {
47
+ const { data: t } = i(a);
48
+ return t;
49
+ }
50
+ export {
51
+ s as F,
52
+ l as e,
53
+ $ as h,
54
+ F as p,
55
+ d as v
56
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";var m=Object.defineProperty;var u=(a,t,r)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r;var s=(a,t,r)=>u(a,typeof t!="symbol"?t+"":t,r);const i=require("gray-matter"),d=require("./manifest-D8kEDc9X.cjs");class o extends Error{constructor(r,e,n){super(r);s(this,"filePath");s(this,"originalError");this.name="FrontmatterParseError",this.filePath=e,this.originalError=n}}function F(a,t){try{const{data:r,content:e}=i(a);return{meta:c(r,t),content:e.trim()}}catch(r){throw r instanceof o?r:new o(`Failed to parse frontmatter${t?` in ${t}`:""}`,t,r)}}function c(a,t){const r=d.DocPageMetaSchema.safeParse(a);if(!r.success){const e=r.error.issues.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
2
+ `);throw new o(`Invalid frontmatter${t?` in ${t}`:""}:
3
+ ${e}`,t,r.error)}return r.data}function h(a){return a.trimStart().startsWith("---")}function f(a){const{data:t}=i(a);return t}exports.FrontmatterParseError=o;exports.extractFrontmatterData=f;exports.hasFrontmatter=h;exports.parseFrontmatter=F;exports.validateFrontmatter=c;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./manifest-CNnJGNwK.cjs");function i(o){const a=[];return r(o.navigation,a),a}function r(o,a){for(const t of o)t.file&&a.push(t.file),t.children&&r(t.children,a)}exports.BreadcrumbItemSchema=e.BreadcrumbItemSchema;exports.DocPageMetaSchema=e.DocPageMetaSchema;exports.DocPageSchema=e.DocPageSchema;exports.DocsPackageManifestSchema=e.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=e.FlatNavigationNodeSchema;exports.FrontmatterParseError=e.FrontmatterParseError;exports.GitHubConfigSchema=e.GitHubConfigSchema;exports.LoadedDocsPackageSchema=e.LoadedDocsPackageSchema;exports.ManifestValidationError=e.ManifestValidationError;exports.NavigationNodeSchema=e.NavigationNodeSchema;exports.SearchConfigSchema=e.SearchConfigSchema;exports.VendureVersionSchema=e.VendureVersionSchema;exports.buildBreadcrumbs=e.buildBreadcrumbs;exports.extractFrontmatterData=e.extractFrontmatterData;exports.findNavigationNode=e.findNavigationNode;exports.flattenNavigation=e.flattenNavigation;exports.getLeafNodes=e.getLeafNodes;exports.getNodesAtDepth=e.getNodesAtDepth;exports.getPrevNextNodes=e.getPrevNextNodes;exports.hasFrontmatter=e.hasFrontmatter;exports.isNodeActive=e.isNodeActive;exports.parseFrontmatter=e.parseFrontmatter;exports.validateFrontmatter=e.validateFrontmatter;exports.validateManifest=e.validateManifest;exports.getAllFilePaths=i;
1
+ "use strict";var L=Object.defineProperty;var R=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var S=(e,t,r)=>R(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./manifest-D8kEDc9X.cjs"),g=require("./frontmatter-_wRoVeyd.cjs"),l=require("./slug-utils-DUQgikEz.cjs"),N=require("fs"),y=require("path"),I=(e,t)=>e.order!==t.order?e.order-t.order:e.title.localeCompare(t.title);function j(e,t={}){const{extensions:r=[".mdx",".md"],filter:i,sort:o=I}=t,n=C(e,r);return(i?n.filter(i):n).sort(o).map(m=>({title:m.title,slug:m.slug,file:m.path}))}function q(e,t={}){return V(e,t,0)}function V(e,t,r){const{extensions:i=[".mdx",".md"],filter:o,sort:n=I,maxDepth:c=1/0,folderFilter:u}=t,m=N.readdirSync(e,{withFileTypes:!0}),h=[],$=C(e,i),D=(o?$.filter(o):$).sort(n);for(const f of D)h.push({title:f.title,slug:f.slug,file:f.path});if(r<c){const f=m.filter(d=>d.isDirectory());for(const d of f){if(u){const s=y.join(e,d.name);if(!u(d.name,s))continue}const F=y.join(e,d.name),v=V(F,t,r+1);if(v.length>0){const s=B(F,i);h.push({title:(s==null?void 0:s.title)||l.titleFromFilename(d.name),slug:l.slugFromFilename(d.name),file:s==null?void 0:s.path,children:v.filter(P=>!(s&&P.file===s.path))})}}}return h.sort((f,d)=>{var E,w;const F=D.find(M=>M.slug===f.slug),v=D.find(M=>M.slug===d.slug);if(F&&v)return n(F,v);const s=!!f.file&&!((E=f.children)!=null&&E.length),P=!!d.file&&!((w=d.children)!=null&&w.length);return s!==P?s?-1:1:(f.title||"").localeCompare(d.title||"")})}function C(e,t){try{const r=N.readdirSync(e,{withFileTypes:!0}),i=[];for(const o of r){if(!o.isFile())continue;const n=t.find(h=>o.name.toLowerCase().endsWith(h));if(!n||o.name.slice(0,-n.length).toLowerCase()==="index")continue;const u=y.join(e,o.name),m=k(u,o.name,n);i.push(m)}return i}catch{return[]}}function k(e,t,r){let i={},o=l.titleFromFilename(t),n=1/0;try{const c=N.readFileSync(e,"utf-8");i=g.extractFrontmatterData(c),i.title&&typeof i.title=="string"&&(o=i.title),typeof i.order=="number"&&(n=i.order)}catch{}return{path:e,filename:t,extension:r,frontmatter:i,order:n,title:o,slug:l.slugFromFilename(t)}}function B(e,t){for(const r of t){const i=y.join(e,`index${r}`);try{if(N.statSync(i).isFile())return k(i,`index${r}`,r)}catch{}}}class b extends Error{constructor(r,i,o,n){super(r);S(this,"nodePath");S(this,"filePath");S(this,"originalError");this.name="ManifestResolutionError",this.nodePath=i,this.filePath=o,this.originalError=n}}function T(e,t={}){const{strict:r=!0}=t,i=x(e.navigation,"",r);return{id:e.id,name:e.name,version:e.version,vendureVersion:e.vendureVersion,navigation:i,search:e.search,github:e.github,basePath:e.basePath}}function x(e,t,r){return e.map((i,o)=>U(i,t,o,r))}function U(e,t,r,i){const o=t?`${t}[${r}]`:`navigation[${r}]`;if(e.title&&e.slug)return{title:e.title,slug:e.slug,file:e.file,children:e.children?x(e.children,`${o}.children`,i):void 0,badge:e.badge,hidden:e.hidden};let n=e.title,c=e.slug;if(e.file&&(c||(c=l.slugFromFilename(e.file)),n||(n=W(e.file,o,i))),!n){if(i)throw new b(`Navigation node at ${o} is missing title and has no file to derive it from`,o,e.file);n=c||`Unknown (${r})`}if(!c){if(i)throw new b(`Navigation node at ${o} is missing slug and has no file to derive it from`,o,e.file);c=n?l.slugFromFilename(n):`node-${r}`}return{title:n,slug:c,file:e.file,children:e.children?x(e.children,`${o}.children`,i):void 0,badge:e.badge,hidden:e.hidden}}function W(e,t,r){try{const i=N.readFileSync(e,"utf-8"),o=g.extractFrontmatterData(i);return o.title&&typeof o.title=="string"?o.title:l.titleFromFilename(e)}catch(i){if(r)throw new b(`Failed to read file for title derivation at ${t}: ${e}`,t,e,i);return l.titleFromFilename(e)}}function G(e){return A(e.navigation)}function A(e){for(const t of e)if(!t.title||!t.slug||t.children&&A(t.children))return!0;return!1}exports.BreadcrumbItemSchema=a.BreadcrumbItemSchema;exports.DocPageMetaSchema=a.DocPageMetaSchema;exports.DocPageSchema=a.DocPageSchema;exports.DocsPackageManifestInputSchema=a.DocsPackageManifestInputSchema;exports.DocsPackageManifestSchema=a.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=a.FlatNavigationNodeSchema;exports.GitHubConfigSchema=a.GitHubConfigSchema;exports.LoadedDocsPackageSchema=a.LoadedDocsPackageSchema;exports.ManifestValidationError=a.ManifestValidationError;exports.NavigationNodeInputSchema=a.NavigationNodeInputSchema;exports.NavigationNodeSchema=a.NavigationNodeSchema;exports.SearchConfigSchema=a.SearchConfigSchema;exports.VendureVersionSchema=a.VendureVersionSchema;exports.buildBreadcrumbs=a.buildBreadcrumbs;exports.findNavigationNode=a.findNavigationNode;exports.flattenNavigation=a.flattenNavigation;exports.getLeafNodes=a.getLeafNodes;exports.getNodesAtDepth=a.getNodesAtDepth;exports.getPrevNextNodes=a.getPrevNextNodes;exports.isNodeActive=a.isNodeActive;exports.validateManifest=a.validateManifest;exports.FrontmatterParseError=g.FrontmatterParseError;exports.extractFrontmatterData=g.extractFrontmatterData;exports.hasFrontmatter=g.hasFrontmatter;exports.parseFrontmatter=g.parseFrontmatter;exports.validateFrontmatter=g.validateFrontmatter;exports.filterVisibleNavigation=l.filterVisibleNavigation;exports.getAllFilePaths=l.getAllFilePaths;exports.slugFromFilename=l.slugFromFilename;exports.titleFromFilename=l.titleFromFilename;exports.toSlug=l.toSlug;exports.ManifestResolutionError=b;exports.createNavigationFromFolder=j;exports.createNestedNavigationFromFolder=q;exports.manifestNeedsResolution=G;exports.resolveManifest=T;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- export type { BreadcrumbItem, DocPage, DocPageMeta, DocsPackageManifest, FlatNavigationNode, GitHubConfig, LoadedDocsPackage, NavigationNode, SearchConfig, VendureVersion, } from './types';
2
- export { BreadcrumbItemSchema, DocPageMetaSchema, DocPageSchema, DocsPackageManifestSchema, FlatNavigationNodeSchema, GitHubConfigSchema, LoadedDocsPackageSchema, NavigationNodeSchema, SearchConfigSchema, VendureVersionSchema, } from './schema';
1
+ export type { BreadcrumbItem, DocPage, DocPageMeta, DocsPackageManifest, DocsPackageManifestInput, FlatNavigationNode, GitHubConfig, LoadedDocsPackage, NavigationNode, NavigationNodeInput, SearchConfig, VendureVersion, } from './types';
2
+ export { BreadcrumbItemSchema, DocPageMetaSchema, DocPageSchema, DocsPackageManifestInputSchema, DocsPackageManifestSchema, FlatNavigationNodeSchema, GitHubConfigSchema, LoadedDocsPackageSchema, NavigationNodeInputSchema, NavigationNodeSchema, SearchConfigSchema, VendureVersionSchema, } from './schema';
3
3
  export { FrontmatterParseError, extractFrontmatterData, hasFrontmatter, parseFrontmatter, validateFrontmatter, } from './frontmatter';
4
4
  export type { ParsedFrontmatter } from './frontmatter';
5
5
  export { ManifestValidationError, buildBreadcrumbs, findNavigationNode, flattenNavigation, getLeafNodes, getNodesAtDepth, getPrevNextNodes, isNodeActive, validateManifest, } from './manifest';
6
- export { getAllFilePaths } from './navigation-utils';
7
- export type { CustomFieldPropertyProps, GenerationInfoProps, GraphQLDocProps, MdxComponentProps, MemberDescriptionProps, MemberInfoProps, StackblitzProps, } from './mdx-components';
6
+ export { filterVisibleNavigation, getAllFilePaths } from './navigation-utils';
7
+ export type { CustomFieldPropertyProps, GenerationInfoProps, GraphQLDocProps, LinkCardProps, MdxComponentProps, MemberDescriptionProps, MemberInfoProps, StackblitzProps, } from './mdx-components';
8
+ export { slugFromFilename, titleFromFilename, toSlug } from './slug-utils';
9
+ export { createNavigationFromFolder, createNestedNavigationFromFolder } from './folder-utils';
10
+ export type { CreateNavigationFromFolderOptions, CreateNestedNavigationFromFolderOptions, FileInfo, } from './folder-utils';
11
+ export { ManifestResolutionError, manifestNeedsResolution, resolveManifest, } from './manifest-resolver';
12
+ export type { ResolveManifestOptions } from './manifest-resolver';
8
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGtD,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGpD,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa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