@vendure-io/docs-provider 0.3.0 → 0.4.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 +97 -17
- package/dist/folder-utils.d.ts +136 -0
- package/dist/folder-utils.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +240 -31
- package/dist/loader.cjs +1 -1
- package/dist/loader.js +1 -1
- package/dist/manifest-BYUKRuRu.cjs +3 -0
- package/dist/manifest-CVIfw0ha.js +228 -0
- package/dist/manifest-resolver.d.ts +59 -0
- package/dist/manifest-resolver.d.ts.map +1 -0
- package/dist/mdx-components.d.ts +26 -1
- package/dist/mdx-components.d.ts.map +1 -1
- package/dist/schema.d.ts +110 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/slug-utils.d.ts +52 -0
- package/dist/slug-utils.d.ts.map +1 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/creating-a-docs-package.md +79 -0
- package/docs/frontmatter-reference.md +36 -0
- package/docs/manifest-reference.md +248 -1
- package/docs/mdx-components-reference.md +31 -0
- package/package.json +1 -1
- package/dist/manifest-BJ3t6hu2.js +0 -208
- package/dist/manifest-CNnJGNwK.cjs +0 -3
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'
|
|
@@ -158,19 +220,22 @@ if (hasFrontmatter(mdxContent)) {
|
|
|
158
220
|
|
|
159
221
|
### Types
|
|
160
222
|
|
|
161
|
-
| Type
|
|
162
|
-
|
|
|
163
|
-
| `DocsPackageManifest`
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
167
|
-
| `
|
|
168
|
-
| `
|
|
169
|
-
| `
|
|
170
|
-
| `
|
|
171
|
-
| `
|
|
172
|
-
| `
|
|
173
|
-
| `
|
|
223
|
+
| Type | Description |
|
|
224
|
+
| -------------------------- | ------------------------------------------------------ |
|
|
225
|
+
| `DocsPackageManifest` | Main manifest describing a documentation package |
|
|
226
|
+
| `DocsPackageManifestInput` | Manifest input with optional title/slug in navigation |
|
|
227
|
+
| `NavigationNode` | A node in the navigation tree |
|
|
228
|
+
| `NavigationNodeInput` | Navigation node input with optional title/slug |
|
|
229
|
+
| `DocPage` | A loaded documentation page with metadata and content |
|
|
230
|
+
| `DocPageMeta` | Frontmatter metadata for a page |
|
|
231
|
+
| `ParsedFrontmatter` | Result of parsing frontmatter (meta + content) |
|
|
232
|
+
| `SearchConfig` | Search indexing configuration |
|
|
233
|
+
| `VendureVersion` | Supported Vendure versions (`'v1' \| 'v2' \| 'v3'`) |
|
|
234
|
+
| `FlatNavigationNode` | Flattened navigation node with path info |
|
|
235
|
+
| `BreadcrumbItem` | Breadcrumb navigation item |
|
|
236
|
+
| `LoadedDocsPackage` | Result of loading a docs package |
|
|
237
|
+
| `GitHubConfig` | GitHub repository configuration for edit links |
|
|
238
|
+
| `FileInfo` | Information about a discovered file (for folder utils) |
|
|
174
239
|
|
|
175
240
|
### MDX Component Props
|
|
176
241
|
|
|
@@ -188,7 +253,9 @@ if (hasFrontmatter(mdxContent)) {
|
|
|
188
253
|
All types have corresponding Zod schemas for runtime validation:
|
|
189
254
|
|
|
190
255
|
- `DocsPackageManifestSchema`
|
|
256
|
+
- `DocsPackageManifestInputSchema`
|
|
191
257
|
- `NavigationNodeSchema`
|
|
258
|
+
- `NavigationNodeInputSchema`
|
|
192
259
|
- `DocPageSchema`
|
|
193
260
|
- `DocPageMetaSchema`
|
|
194
261
|
- `SearchConfigSchema`
|
|
@@ -205,6 +272,8 @@ All types have corresponding Zod schemas for runtime validation:
|
|
|
205
272
|
| Function | Description |
|
|
206
273
|
| ---------------------------------------- | ----------------------------------------- |
|
|
207
274
|
| `validateManifest(data)` | Validate raw data against manifest schema |
|
|
275
|
+
| `resolveManifest(input, options?)` | Resolve manifest input to full manifest |
|
|
276
|
+
| `manifestNeedsResolution(input)` | Check if manifest input needs resolution |
|
|
208
277
|
| `findNavigationNode(manifest, slugPath)` | Find a node by slug path |
|
|
209
278
|
| `flattenNavigation(manifest)` | Flatten navigation tree to array |
|
|
210
279
|
| `buildBreadcrumbs(manifest, slugPath)` | Build breadcrumb trail |
|
|
@@ -215,9 +284,19 @@ All types have corresponding Zod schemas for runtime validation:
|
|
|
215
284
|
|
|
216
285
|
#### Navigation Utilities
|
|
217
286
|
|
|
218
|
-
| Function
|
|
219
|
-
|
|
|
220
|
-
| `getAllFilePaths(manifest)`
|
|
287
|
+
| Function | Description |
|
|
288
|
+
| ----------------------------------------------- | -------------------------------------- |
|
|
289
|
+
| `getAllFilePaths(manifest)` | Get all file paths from manifest |
|
|
290
|
+
| `createNavigationFromFolder(path, options?)` | Create navigation from folder contents |
|
|
291
|
+
| `createNestedNavigationFromFolder(path, opts?)` | Create nested navigation from folders |
|
|
292
|
+
|
|
293
|
+
#### Slug Utilities
|
|
294
|
+
|
|
295
|
+
| Function | Description |
|
|
296
|
+
| ------------------------- | ------------------------------- |
|
|
297
|
+
| `toSlug(text)` | Convert text to kebab-case slug |
|
|
298
|
+
| `slugFromFilename(file)` | Extract slug from filename |
|
|
299
|
+
| `titleFromFilename(file)` | Generate title from filename |
|
|
221
300
|
|
|
222
301
|
#### Frontmatter Utilities
|
|
223
302
|
|
|
@@ -233,6 +312,7 @@ All types have corresponding Zod schemas for runtime validation:
|
|
|
233
312
|
| Class | Description |
|
|
234
313
|
| ------------------------- | ------------------------------------- |
|
|
235
314
|
| `ManifestValidationError` | Thrown when manifest validation fails |
|
|
315
|
+
| `ManifestResolutionError` | Thrown when manifest resolution fails |
|
|
236
316
|
| `FrontmatterParseError` | Thrown when frontmatter parsing fails |
|
|
237
317
|
|
|
238
318
|
## Development
|
|
@@ -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,CAAA;IACZ,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAA;IACb,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IAErB;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAA;IAEpC;;;OAGG;IACH,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,KAAK,MAAM,CAAA;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,uCAAwC,SAAQ,iCAAiC;IAChG;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAA;CACnE;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,iCAAsC,GAC9C,mBAAmB,EAAE,CAYvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,uCAA4C,GACpD,mBAAmB,EAAE,CAEvB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";var A=Object.defineProperty;var R=(e,t,i)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var S=(e,t,i)=>R(e,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./manifest-BYUKRuRu.cjs"),N=require("fs"),x=require("path");function j(e){const t=[];return $(e.navigation,t),t}function $(e,t){for(const i of e)i.file&&t.push(i.file),i.children&&$(i.children,t)}function C(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function F(e){const r=(e.split("/").pop()||e).replace(/\.(mdx?|md)$/i,"").replace(/^\d+-/,"");return C(r)}function v(e){return(e.split("/").pop()||e).replace(/\.(mdx?|md)$/i,"").replace(/^\d+-/,"").replace(/[-_]+/g," ").toLowerCase().replace(/\b\w/g,o=>o.toUpperCase()).trim()}const I=(e,t)=>e.order!==t.order?e.order-t.order:e.title.localeCompare(t.title);function B(e,t={}){const{extensions:i=[".mdx",".md"],filter:r,sort:o=I}=t,a=V(e,i);return(r?a.filter(r):a).sort(o).map(d=>({title:d.title,slug:d.slug,file:d.path}))}function T(e,t={}){return L(e,t,0)}function L(e,t,i){const{extensions:r=[".mdx",".md"],filter:o,sort:a=I,maxDepth:l=1/0,folderFilter:u}=t,d=N.readdirSync(e,{withFileTypes:!0}),m=[],D=V(e,r),P=(o?D.filter(o):D).sort(a);for(const f of P)m.push({title:f.title,slug:f.slug,file:f.path});if(i<l){const f=d.filter(c=>c.isDirectory());for(const c of f){if(u){const s=x.join(e,c.name);if(!u(c.name,s))continue}const g=x.join(e,c.name),h=L(g,t,i+1);if(h.length>0){const s=q(g,r);m.push({title:(s==null?void 0:s.title)||v(c.name),slug:F(c.name),file:s==null?void 0:s.path,children:h.filter(p=>!(s&&p.file===s.path))})}}}return m.sort((f,c)=>{var E,M;const g=P.find(y=>y.slug===f.slug),h=P.find(y=>y.slug===c.slug);if(g&&h)return a(g,h);const s=!!f.file&&!((E=f.children)!=null&&E.length),p=!!c.file&&!((M=c.children)!=null&&M.length);return s!==p?s?-1:1:(f.title||"").localeCompare(c.title||"")})}function V(e,t){try{const i=N.readdirSync(e,{withFileTypes:!0}),r=[];for(const o of i){if(!o.isFile())continue;const a=t.find(m=>o.name.toLowerCase().endsWith(m));if(!a||o.name.slice(0,-a.length).toLowerCase()==="index")continue;const u=x.join(e,o.name),d=k(u,o.name,a);r.push(d)}return r}catch{return[]}}function k(e,t,i){let r={},o=v(t),a=1/0;try{const l=N.readFileSync(e,"utf-8");r=n.extractFrontmatterData(l),r.title&&typeof r.title=="string"&&(o=r.title),typeof r.order=="number"&&(a=r.order)}catch{}return{path:e,filename:t,extension:i,frontmatter:r,order:a,title:o,slug:F(t)}}function q(e,t){for(const i of t){const r=x.join(e,`index${i}`);try{if(N.statSync(r).isFile())return k(r,`index${i}`,i)}catch{}}}class b extends Error{constructor(i,r,o,a){super(i);S(this,"nodePath");S(this,"filePath");S(this,"originalError");this.name="ManifestResolutionError",this.nodePath=r,this.filePath=o,this.originalError=a}}function U(e,t={}){const{strict:i=!0}=t,r=w(e.navigation,"",i);return{id:e.id,name:e.name,version:e.version,vendureVersion:e.vendureVersion,navigation:r,search:e.search,github:e.github,basePath:e.basePath}}function w(e,t,i){return e.map((r,o)=>G(r,t,o,i))}function G(e,t,i,r){const o=t?`${t}[${i}]`:`navigation[${i}]`;if(e.title&&e.slug)return{title:e.title,slug:e.slug,file:e.file,children:e.children?w(e.children,`${o}.children`,r):void 0,badge:e.badge};let a=e.title,l=e.slug;if(e.file&&(l||(l=F(e.file)),a||(a=H(e.file,o,r))),!a){if(r)throw new b(`Navigation node at ${o} is missing title and has no file to derive it from`,o,e.file);a=l||`Unknown (${i})`}if(!l){if(r)throw new b(`Navigation node at ${o} is missing slug and has no file to derive it from`,o,e.file);l=a?F(a):`node-${i}`}return{title:a,slug:l,file:e.file,children:e.children?w(e.children,`${o}.children`,r):void 0,badge:e.badge}}function H(e,t,i){try{const r=N.readFileSync(e,"utf-8"),o=n.extractFrontmatterData(r);return o.title&&typeof o.title=="string"?o.title:v(e)}catch(r){if(i)throw new b(`Failed to read file for title derivation at ${t}: ${e}`,t,e,r);return v(e)}}function O(e){return W(e.navigation)}function W(e){for(const t of e)if(!t.title||!t.slug||t.children&&W(t.children))return!0;return!1}exports.BreadcrumbItemSchema=n.BreadcrumbItemSchema;exports.DocPageMetaSchema=n.DocPageMetaSchema;exports.DocPageSchema=n.DocPageSchema;exports.DocsPackageManifestInputSchema=n.DocsPackageManifestInputSchema;exports.DocsPackageManifestSchema=n.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=n.FlatNavigationNodeSchema;exports.FrontmatterParseError=n.FrontmatterParseError;exports.GitHubConfigSchema=n.GitHubConfigSchema;exports.LoadedDocsPackageSchema=n.LoadedDocsPackageSchema;exports.ManifestValidationError=n.ManifestValidationError;exports.NavigationNodeInputSchema=n.NavigationNodeInputSchema;exports.NavigationNodeSchema=n.NavigationNodeSchema;exports.SearchConfigSchema=n.SearchConfigSchema;exports.VendureVersionSchema=n.VendureVersionSchema;exports.buildBreadcrumbs=n.buildBreadcrumbs;exports.extractFrontmatterData=n.extractFrontmatterData;exports.findNavigationNode=n.findNavigationNode;exports.flattenNavigation=n.flattenNavigation;exports.getLeafNodes=n.getLeafNodes;exports.getNodesAtDepth=n.getNodesAtDepth;exports.getPrevNextNodes=n.getPrevNextNodes;exports.hasFrontmatter=n.hasFrontmatter;exports.isNodeActive=n.isNodeActive;exports.parseFrontmatter=n.parseFrontmatter;exports.validateFrontmatter=n.validateFrontmatter;exports.validateManifest=n.validateManifest;exports.ManifestResolutionError=b;exports.createNavigationFromFolder=B;exports.createNestedNavigationFromFolder=T;exports.getAllFilePaths=j;exports.manifestNeedsResolution=O;exports.resolveManifest=U;exports.slugFromFilename=F;exports.titleFromFilename=v;exports.toSlug=C;
|
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
6
|
export { getAllFilePaths } from './navigation-utils';
|
|
7
|
-
export type { CustomFieldPropertyProps, GenerationInfoProps, GraphQLDocProps, MdxComponentProps, MemberDescriptionProps, MemberInfoProps, StackblitzProps, } from './mdx-components';
|
|
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,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,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,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1E,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAA;AAC7F,YAAY,EACV,iCAAiC,EACjC,uCAAuC,EACvC,QAAQ,GACT,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,245 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var A = (e, t, r) => t in e ? R(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var g = (e, t, r) => A(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { e as P } from "./manifest-CVIfw0ha.js";
|
|
5
|
+
import { B as te, D as ie, a as re, b as ne, c as oe, F as se, f as ae, G as le, L as ce, M as fe, N as de, d as ue, S as me, V as he, g as ge, i as ve, j as Fe, k as Ne, l as xe, m as pe, h as Se, n as we, p as be, v as ye, o as $e } from "./manifest-CVIfw0ha.js";
|
|
6
|
+
import { readdirSync as C, readFileSync as D, statSync as B } from "fs";
|
|
7
|
+
import { join as v } from "path";
|
|
8
|
+
function K(e) {
|
|
9
|
+
const t = [];
|
|
10
|
+
return M(e.navigation, t), t;
|
|
5
11
|
}
|
|
6
|
-
function
|
|
7
|
-
for (const
|
|
8
|
-
|
|
12
|
+
function M(e, t) {
|
|
13
|
+
for (const r of e)
|
|
14
|
+
r.file && t.push(r.file), r.children && M(r.children, t);
|
|
15
|
+
}
|
|
16
|
+
function T(e) {
|
|
17
|
+
return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
18
|
+
}
|
|
19
|
+
function F(e) {
|
|
20
|
+
const i = (e.split("/").pop() || e).replace(/\.(mdx?|md)$/i, "").replace(/^\d+-/, "");
|
|
21
|
+
return T(i);
|
|
22
|
+
}
|
|
23
|
+
function N(e) {
|
|
24
|
+
return (e.split("/").pop() || e).replace(/\.(mdx?|md)$/i, "").replace(/^\d+-/, "").replace(/[-_]+/g, " ").toLowerCase().replace(/\b\w/g, (n) => n.toUpperCase()).trim();
|
|
25
|
+
}
|
|
26
|
+
const I = (e, t) => e.order !== t.order ? e.order - t.order : e.title.localeCompare(t.title);
|
|
27
|
+
function O(e, t = {}) {
|
|
28
|
+
const { extensions: r = [".mdx", ".md"], filter: i, sort: n = I } = t, o = W(e, r);
|
|
29
|
+
return (i ? o.filter(i) : o).sort(n).map((f) => ({
|
|
30
|
+
title: f.title,
|
|
31
|
+
slug: f.slug,
|
|
32
|
+
file: f.path
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
function Q(e, t = {}) {
|
|
36
|
+
return L(e, t, 0);
|
|
37
|
+
}
|
|
38
|
+
function L(e, t, r) {
|
|
39
|
+
const {
|
|
40
|
+
extensions: i = [".mdx", ".md"],
|
|
41
|
+
filter: n,
|
|
42
|
+
sort: o = I,
|
|
43
|
+
maxDepth: a = 1 / 0,
|
|
44
|
+
folderFilter: d
|
|
45
|
+
} = t, f = C(e, { withFileTypes: !0 }), u = [], y = W(e, i), x = (n ? y.filter(n) : y).sort(o);
|
|
46
|
+
for (const c of x)
|
|
47
|
+
u.push({
|
|
48
|
+
title: c.title,
|
|
49
|
+
slug: c.slug,
|
|
50
|
+
file: c.path
|
|
51
|
+
});
|
|
52
|
+
if (r < a) {
|
|
53
|
+
const c = f.filter((l) => l.isDirectory());
|
|
54
|
+
for (const l of c) {
|
|
55
|
+
if (d) {
|
|
56
|
+
const s = v(e, l.name);
|
|
57
|
+
if (!d(l.name, s))
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const m = v(e, l.name), h = L(m, t, r + 1);
|
|
61
|
+
if (h.length > 0) {
|
|
62
|
+
const s = U(m, i);
|
|
63
|
+
u.push({
|
|
64
|
+
title: (s == null ? void 0 : s.title) || N(l.name),
|
|
65
|
+
slug: F(l.name),
|
|
66
|
+
file: s == null ? void 0 : s.path,
|
|
67
|
+
children: h.filter((p) => !(s && p.file === s.path))
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return u.sort((c, l) => {
|
|
73
|
+
var $, E;
|
|
74
|
+
const m = x.find((S) => S.slug === c.slug), h = x.find((S) => S.slug === l.slug);
|
|
75
|
+
if (m && h)
|
|
76
|
+
return o(m, h);
|
|
77
|
+
const s = !!c.file && !(($ = c.children) != null && $.length), p = !!l.file && !((E = l.children) != null && E.length);
|
|
78
|
+
return s !== p ? s ? -1 : 1 : (c.title || "").localeCompare(l.title || "");
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function W(e, t) {
|
|
82
|
+
try {
|
|
83
|
+
const r = C(e, { withFileTypes: !0 }), i = [];
|
|
84
|
+
for (const n of r) {
|
|
85
|
+
if (!n.isFile()) continue;
|
|
86
|
+
const o = t.find((u) => n.name.toLowerCase().endsWith(u));
|
|
87
|
+
if (!o || n.name.slice(0, -o.length).toLowerCase() === "index") continue;
|
|
88
|
+
const d = v(e, n.name), f = V(d, n.name, o);
|
|
89
|
+
i.push(f);
|
|
90
|
+
}
|
|
91
|
+
return i;
|
|
92
|
+
} catch {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function V(e, t, r) {
|
|
97
|
+
let i = {}, n = N(t), o = 1 / 0;
|
|
98
|
+
try {
|
|
99
|
+
const a = D(e, "utf-8");
|
|
100
|
+
i = P(a), i.title && typeof i.title == "string" && (n = i.title), typeof i.order == "number" && (o = i.order);
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
path: e,
|
|
105
|
+
filename: t,
|
|
106
|
+
extension: r,
|
|
107
|
+
frontmatter: i,
|
|
108
|
+
order: o,
|
|
109
|
+
title: n,
|
|
110
|
+
slug: F(t)
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function U(e, t) {
|
|
114
|
+
for (const r of t) {
|
|
115
|
+
const i = v(e, `index${r}`);
|
|
116
|
+
try {
|
|
117
|
+
if (B(i).isFile())
|
|
118
|
+
return V(i, `index${r}`, r);
|
|
119
|
+
} catch {
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
class w extends Error {
|
|
124
|
+
constructor(r, i, n, o) {
|
|
125
|
+
super(r);
|
|
126
|
+
g(this, "nodePath");
|
|
127
|
+
g(this, "filePath");
|
|
128
|
+
g(this, "originalError");
|
|
129
|
+
this.name = "ManifestResolutionError", this.nodePath = i, this.filePath = n, this.originalError = o;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function X(e, t = {}) {
|
|
133
|
+
const { strict: r = !0 } = t, i = b(e.navigation, "", r);
|
|
134
|
+
return {
|
|
135
|
+
id: e.id,
|
|
136
|
+
name: e.name,
|
|
137
|
+
version: e.version,
|
|
138
|
+
vendureVersion: e.vendureVersion,
|
|
139
|
+
navigation: i,
|
|
140
|
+
search: e.search,
|
|
141
|
+
github: e.github,
|
|
142
|
+
basePath: e.basePath
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function b(e, t, r) {
|
|
146
|
+
return e.map((i, n) => j(i, t, n, r));
|
|
147
|
+
}
|
|
148
|
+
function j(e, t, r, i) {
|
|
149
|
+
const n = t ? `${t}[${r}]` : `navigation[${r}]`;
|
|
150
|
+
if (e.title && e.slug)
|
|
151
|
+
return {
|
|
152
|
+
title: e.title,
|
|
153
|
+
slug: e.slug,
|
|
154
|
+
file: e.file,
|
|
155
|
+
children: e.children ? b(e.children, `${n}.children`, i) : void 0,
|
|
156
|
+
badge: e.badge
|
|
157
|
+
};
|
|
158
|
+
let o = e.title, a = e.slug;
|
|
159
|
+
if (e.file && (a || (a = F(e.file)), o || (o = G(e.file, n, i))), !o) {
|
|
160
|
+
if (i)
|
|
161
|
+
throw new w(
|
|
162
|
+
`Navigation node at ${n} is missing title and has no file to derive it from`,
|
|
163
|
+
n,
|
|
164
|
+
e.file
|
|
165
|
+
);
|
|
166
|
+
o = a || `Unknown (${r})`;
|
|
167
|
+
}
|
|
168
|
+
if (!a) {
|
|
169
|
+
if (i)
|
|
170
|
+
throw new w(
|
|
171
|
+
`Navigation node at ${n} is missing slug and has no file to derive it from`,
|
|
172
|
+
n,
|
|
173
|
+
e.file
|
|
174
|
+
);
|
|
175
|
+
a = o ? F(o) : `node-${r}`;
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
title: o,
|
|
179
|
+
slug: a,
|
|
180
|
+
file: e.file,
|
|
181
|
+
children: e.children ? b(e.children, `${n}.children`, i) : void 0,
|
|
182
|
+
badge: e.badge
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function G(e, t, r) {
|
|
186
|
+
try {
|
|
187
|
+
const i = D(e, "utf-8"), n = P(i);
|
|
188
|
+
return n.title && typeof n.title == "string" ? n.title : N(e);
|
|
189
|
+
} catch (i) {
|
|
190
|
+
if (r)
|
|
191
|
+
throw new w(
|
|
192
|
+
`Failed to read file for title derivation at ${t}: ${e}`,
|
|
193
|
+
t,
|
|
194
|
+
e,
|
|
195
|
+
i
|
|
196
|
+
);
|
|
197
|
+
return N(e);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function Y(e) {
|
|
201
|
+
return k(e.navigation);
|
|
202
|
+
}
|
|
203
|
+
function k(e) {
|
|
204
|
+
for (const t of e)
|
|
205
|
+
if (!t.title || !t.slug || t.children && k(t.children))
|
|
206
|
+
return !0;
|
|
207
|
+
return !1;
|
|
9
208
|
}
|
|
10
209
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
210
|
+
te as BreadcrumbItemSchema,
|
|
211
|
+
ie as DocPageMetaSchema,
|
|
212
|
+
re as DocPageSchema,
|
|
213
|
+
ne as DocsPackageManifestInputSchema,
|
|
214
|
+
oe as DocsPackageManifestSchema,
|
|
215
|
+
se as FlatNavigationNodeSchema,
|
|
216
|
+
ae as FrontmatterParseError,
|
|
217
|
+
le as GitHubConfigSchema,
|
|
218
|
+
ce as LoadedDocsPackageSchema,
|
|
219
|
+
w as ManifestResolutionError,
|
|
220
|
+
fe as ManifestValidationError,
|
|
221
|
+
de as NavigationNodeInputSchema,
|
|
222
|
+
ue as NavigationNodeSchema,
|
|
223
|
+
me as SearchConfigSchema,
|
|
224
|
+
he as VendureVersionSchema,
|
|
225
|
+
ge as buildBreadcrumbs,
|
|
226
|
+
O as createNavigationFromFolder,
|
|
227
|
+
Q as createNestedNavigationFromFolder,
|
|
24
228
|
P as extractFrontmatterData,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
229
|
+
ve as findNavigationNode,
|
|
230
|
+
Fe as flattenNavigation,
|
|
231
|
+
K as getAllFilePaths,
|
|
232
|
+
Ne as getLeafNodes,
|
|
233
|
+
xe as getNodesAtDepth,
|
|
234
|
+
pe as getPrevNextNodes,
|
|
235
|
+
Se as hasFrontmatter,
|
|
236
|
+
we as isNodeActive,
|
|
237
|
+
Y as manifestNeedsResolution,
|
|
238
|
+
be as parseFrontmatter,
|
|
239
|
+
X as resolveManifest,
|
|
240
|
+
F as slugFromFilename,
|
|
241
|
+
N as titleFromFilename,
|
|
242
|
+
T as toSlug,
|
|
243
|
+
ye as validateFrontmatter,
|
|
244
|
+
$e as validateManifest
|
|
36
245
|
};
|
package/dist/loader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var h=(e,r,t)=>r in e?g(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r,t)=>h(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("fs/promises"),m=require("module"),u=require("./manifest-
|
|
1
|
+
"use strict";var g=Object.defineProperty;var h=(e,r,t)=>r in e?g(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r,t)=>h(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("fs/promises"),m=require("module"),u=require("./manifest-BYUKRuRu.cjs");var c=typeof document<"u"?document.currentScript:null;class a extends Error{constructor(t,n){super(t);i(this,"packageName");this.name="DocsPackageLoadError",this.packageName=n}}async function p(e,r={}){try{const t=r.resolver?await r.resolver(e):l(e),n=await import(e);if(!n.manifest)throw new a(`Package "${e}" does not export a manifest`,e);return{manifest:u.validateManifest(n.manifest),basePath:t}}catch(t){throw t instanceof a?t:new a(`Failed to load docs package "${e}": ${t instanceof Error?t.message:String(t)}`,e)}}function l(e){try{return m.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("loader.cjs",document.baseURI).href).resolve(`${e}/package.json`).replace(/\/package\.json$/,"")}catch{throw new a(`Cannot resolve package "${e}". Make sure it is installed.`,e)}}async function d(e,r){try{const t=`${e.basePath}/${r}`,n=await P.readFile(t,"utf-8"),{meta:o,content:s}=u.parseFrontmatter(n,r);return{meta:o,content:s,filePath:r}}catch(t){throw new a(`Failed to load doc page "${r}": ${t instanceof Error?t.message:String(t)}`,e.manifest.id)}}async function $(e,r){const t=f(e.manifest.navigation,r.split("/"));if(t!=null&&t.file)return d(e,t.file)}function f(e,r){if(r.length===0)return;const[t,...n]=r,o=e.find(s=>s.slug===t);if(o){if(n.length===0)return o;if(o.children)return f(o.children,n)}}function v(e,r){if(r.file)return`${e.basePath}/${r.file}`}function y(e){try{return l(e),!0}catch{return!1}}exports.DocsPackageLoadError=a;exports.isDocsPackageInstalled=y;exports.loadDocPage=d;exports.loadDocPageBySlug=$;exports.loadDocsPackage=p;exports.resolveFilePath=v;
|
package/dist/loader.js
CHANGED
|
@@ -3,7 +3,7 @@ var l = (t, e, r) => e in t ? f(t, e, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var i = (t, e, r) => l(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
4
|
import { readFile as d } from "fs/promises";
|
|
5
5
|
import { createRequire as h } from "module";
|
|
6
|
-
import {
|
|
6
|
+
import { o as g, p as m } from "./manifest-CVIfw0ha.js";
|
|
7
7
|
class a extends Error {
|
|
8
8
|
constructor(r, n) {
|
|
9
9
|
super(r);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var $=Object.defineProperty;var k=(r,e,n)=>e in r?$(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var l=(r,e,n)=>k(r,typeof e!="symbol"?e+"":e,n);const b=require("gray-matter"),t=require("zod"),u=t.z.enum(["v1","v2","v3"]),m=t.z.object({indexFields:t.z.array(t.z.enum(["title","description","content","keywords"])),boosts:t.z.record(t.z.string(),t.z.number()).optional()}),h=t.z.object({repository:t.z.string().regex(/^[^/]+\/[^/]+$/,'Repository must be in format "owner/repo"'),branch:t.z.string().optional(),docsPath:t.z.string().optional()}),g=t.z.lazy(()=>t.z.object({title:t.z.string().min(1,"Navigation title is required"),slug:t.z.string().min(1,"Navigation slug is required"),file:t.z.string().optional(),children:t.z.array(g).optional(),badge:t.z.string().optional()})),f=t.z.object({id:t.z.string().min(1,"Package ID is required"),name:t.z.string().min(1,"Package name is required"),version:t.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:u,navigation:t.z.array(g),search:m.optional(),github:h.optional(),basePath:t.z.string().optional()}),z=t.z.object({title:t.z.string().min(1,"Page title is required"),description:t.z.string().optional(),keywords:t.z.array(t.z.string()).optional(),sidebarLabel:t.z.string().optional(),hidden:t.z.boolean().optional(),order:t.z.number().int().optional()}),x=t.z.object({meta:z,content:t.z.string(),filePath:t.z.string()}),M=t.z.object({manifest:f,basePath:t.z.string()}),I=t.z.object({title:t.z.string(),slug:t.z.string(),path:t.z.string()}),V=t.z.object({title:t.z.string(),slug:t.z.string(),file:t.z.string().optional(),children:t.z.array(t.z.lazy(()=>g)).optional(),badge:t.z.string().optional(),path:t.z.string(),depth:t.z.number().int().min(0),parentPath:t.z.string().optional()}),p=t.z.lazy(()=>t.z.object({title:t.z.string().min(1).optional(),slug:t.z.string().min(1).optional(),file:t.z.string().optional(),children:t.z.array(p).optional(),badge:t.z.string().optional()})),w=t.z.object({id:t.z.string().min(1,"Package ID is required"),name:t.z.string().min(1,"Package name is required"),version:t.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:u,navigation:t.z.array(p),search:m.optional(),github:h.optional(),basePath:t.z.string().optional()});class d extends Error{constructor(n,i,a){super(n);l(this,"filePath");l(this,"originalError");this.name="FrontmatterParseError",this.filePath=i,this.originalError=a}}function E(r,e){try{const{data:n,content:i}=b(r);return{meta:N(n,e),content:i.trim()}}catch(n){throw n instanceof d?n:new d(`Failed to parse frontmatter${e?` in ${e}`:""}`,e,n)}}function N(r,e){const n=z.safeParse(r);if(!n.success){const i=n.error.issues.map(a=>` - ${a.path.join(".")}: ${a.message}`).join(`
|
|
2
|
+
`);throw new d(`Invalid frontmatter${e?` in ${e}`:""}:
|
|
3
|
+
${i}`,e,n.error)}return n.data}function q(r){return r.trimStart().startsWith("---")}function B(r){const{data:e}=b(r);return e}class S extends Error{constructor(n,i){super(n);l(this,"issues");this.name="ManifestValidationError",this.issues=i}}function L(r){const e=f.safeParse(r);if(!e.success){const n=e.error.issues.map(i=>`${i.path.join(".")}: ${i.message}`);throw new S("Invalid manifest",n)}return e.data}function A(r,e){const n=e.split("/").filter(Boolean);return P(r.navigation,n)}function P(r,e){if(e.length===0)return;const[n,...i]=e,a=r.find(o=>o.slug===n);if(a){if(i.length===0)return a;if(a.children)return P(a.children,i)}}function v(r){const e=[];return y(r.navigation,"",0,void 0,e),e}function y(r,e,n,i,a){for(const o of r){const s=e?`${e}/${o.slug}`:o.slug;a.push({...o,path:s,depth:n,parentPath:i}),o.children&&o.children.length>0&&y(o.children,s,n+1,s,a)}}function C(r,e){const n=e.split("/").filter(Boolean),i=[];let a=r.navigation,o="";for(const s of n){const c=a.find(F=>F.slug===s);if(!c)break;o=o?`${o}/${s}`:s,i.push({title:c.title,slug:c.slug,path:o}),a=c.children??[]}return i}function D(r){return v(r).filter(e=>e.file!==void 0)}function G(r,e){const n=D(r),i=n.findIndex(a=>a.path===e);return i===-1?{}:{prev:i>0?n[i-1]:void 0,next:i<n.length-1?n[i+1]:void 0}}function j(r,e){const n=e.split("/").filter(Boolean);if(n.length===0)return!1;if(r.slug===n[0]){if(n.length===1)return!0;if(r.children){const i=n.slice(1).join("/");return r.children.some(a=>j(a,i))}}return!1}function H(r,e){return v(r).filter(n=>n.depth===e)}exports.BreadcrumbItemSchema=I;exports.DocPageMetaSchema=z;exports.DocPageSchema=x;exports.DocsPackageManifestInputSchema=w;exports.DocsPackageManifestSchema=f;exports.FlatNavigationNodeSchema=V;exports.FrontmatterParseError=d;exports.GitHubConfigSchema=h;exports.LoadedDocsPackageSchema=M;exports.ManifestValidationError=S;exports.NavigationNodeInputSchema=p;exports.NavigationNodeSchema=g;exports.SearchConfigSchema=m;exports.VendureVersionSchema=u;exports.buildBreadcrumbs=C;exports.extractFrontmatterData=B;exports.findNavigationNode=A;exports.flattenNavigation=v;exports.getLeafNodes=D;exports.getNodesAtDepth=H;exports.getPrevNextNodes=G;exports.hasFrontmatter=q;exports.isNodeActive=j;exports.parseFrontmatter=E;exports.validateFrontmatter=N;exports.validateManifest=L;
|