@vendure-io/docs-provider 0.1.0 → 0.1.1
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 +30 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,10 +22,18 @@ bun add @vendure-io/docs-provider
|
|
|
22
22
|
|
|
23
23
|
### Defining a Documentation Package Manifest
|
|
24
24
|
|
|
25
|
-
Documentation packages export a manifest that describes their structure:
|
|
25
|
+
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
26
|
|
|
27
27
|
```typescript
|
|
28
28
|
import type { DocsPackageManifest } from '@vendure-io/docs-provider'
|
|
29
|
+
import { dirname, join } from 'path'
|
|
30
|
+
import { fileURLToPath } from 'url'
|
|
31
|
+
|
|
32
|
+
// Resolve the package root directory at module load time
|
|
33
|
+
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)))
|
|
34
|
+
|
|
35
|
+
// Helper to resolve file paths to absolute paths
|
|
36
|
+
const file = (relativePath: string) => join(packageRoot, relativePath)
|
|
29
37
|
|
|
30
38
|
export const manifest: DocsPackageManifest = {
|
|
31
39
|
id: 'core',
|
|
@@ -40,12 +48,12 @@ export const manifest: DocsPackageManifest = {
|
|
|
40
48
|
{
|
|
41
49
|
title: 'Installation',
|
|
42
50
|
slug: 'installation',
|
|
43
|
-
file: 'docs/getting-started/installation.mdx',
|
|
51
|
+
file: file('docs/getting-started/installation.mdx'),
|
|
44
52
|
},
|
|
45
53
|
{
|
|
46
54
|
title: 'Configuration',
|
|
47
55
|
slug: 'configuration',
|
|
48
|
-
file: 'docs/getting-started/configuration.mdx',
|
|
56
|
+
file: file('docs/getting-started/configuration.mdx'),
|
|
49
57
|
},
|
|
50
58
|
],
|
|
51
59
|
},
|
|
@@ -54,22 +62,24 @@ export const manifest: DocsPackageManifest = {
|
|
|
54
62
|
indexFields: ['title', 'description', 'content', 'keywords'],
|
|
55
63
|
boosts: { title: 2, keywords: 1.5 },
|
|
56
64
|
},
|
|
65
|
+
github: {
|
|
66
|
+
repository: 'your-org/your-repo',
|
|
67
|
+
branch: 'main',
|
|
68
|
+
docsPath: 'libs/your-docs-package',
|
|
69
|
+
},
|
|
57
70
|
}
|
|
58
71
|
```
|
|
59
72
|
|
|
60
|
-
|
|
73
|
+
Your package should export the manifest from a dedicated entry point. Add the following to your `package.json`:
|
|
61
74
|
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (page) {
|
|
71
|
-
console.log(page.meta.title) // "Installation"
|
|
72
|
-
console.log(page.content) // MDX content
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"exports": {
|
|
78
|
+
"./manifest": {
|
|
79
|
+
"import": "./dist/manifest.js",
|
|
80
|
+
"types": "./dist/manifest.d.ts"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
73
83
|
}
|
|
74
84
|
```
|
|
75
85
|
|
|
@@ -153,6 +163,7 @@ if (hasFrontmatter(mdxContent)) {
|
|
|
153
163
|
| `NavigationNode` | A node in the navigation tree |
|
|
154
164
|
| `DocPage` | A loaded documentation page with metadata and content |
|
|
155
165
|
| `DocPageMeta` | Frontmatter metadata for a page |
|
|
166
|
+
| `ParsedFrontmatter` | Result of parsing frontmatter (meta + content) |
|
|
156
167
|
| `SearchConfig` | Search indexing configuration |
|
|
157
168
|
| `VendureVersion` | Supported Vendure versions (`'v1' \| 'v2' \| 'v3'`) |
|
|
158
169
|
| `FlatNavigationNode` | Flattened navigation node with path info |
|
|
@@ -190,16 +201,11 @@ All types have corresponding Zod schemas for runtime validation:
|
|
|
190
201
|
| `isNodeActive(node, currentPath)` | Check if node matches path |
|
|
191
202
|
| `getNodesAtDepth(manifest, depth)` | Get nodes at specific depth |
|
|
192
203
|
|
|
193
|
-
####
|
|
204
|
+
#### Navigation Utilities
|
|
194
205
|
|
|
195
|
-
| Function
|
|
196
|
-
|
|
|
197
|
-
| `
|
|
198
|
-
| `loadDocPage(package, filePath)` | Load a page by file path |
|
|
199
|
-
| `loadDocPageBySlug(package, slugPath)` | Load a page by slug path |
|
|
200
|
-
| `resolveFilePath(package, node)` | Resolve full file path |
|
|
201
|
-
| `isDocsPackageInstalled(packageName)` | Check if package is installed |
|
|
202
|
-
| `getAllFilePaths(manifest)` | Get all file paths from manifest |
|
|
206
|
+
| Function | Description |
|
|
207
|
+
| --------------------------- | -------------------------------- |
|
|
208
|
+
| `getAllFilePaths(manifest)` | Get all file paths from manifest |
|
|
203
209
|
|
|
204
210
|
#### Frontmatter Utilities
|
|
205
211
|
|
|
@@ -216,7 +222,6 @@ All types have corresponding Zod schemas for runtime validation:
|
|
|
216
222
|
| ------------------------- | ------------------------------------- |
|
|
217
223
|
| `ManifestValidationError` | Thrown when manifest validation fails |
|
|
218
224
|
| `FrontmatterParseError` | Thrown when frontmatter parsing fails |
|
|
219
|
-
| `DocsPackageLoadError` | Thrown when package loading fails |
|
|
220
225
|
|
|
221
226
|
## Development
|
|
222
227
|
|