@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 +136 -17
- package/dist/browser.cjs +1 -0
- package/dist/browser.d.ts +10 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +30 -0
- package/dist/folder-utils.d.ts +136 -0
- package/dist/folder-utils.d.ts.map +1 -0
- package/dist/frontmatter-8Bwpoi8r.js +56 -0
- package/dist/frontmatter-_wRoVeyd.cjs +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +229 -32
- package/dist/loader.cjs +1 -1
- package/dist/loader.js +17 -16
- package/dist/manifest-B_cvT6F9.js +181 -0
- package/dist/manifest-D8kEDc9X.cjs +1 -0
- package/dist/manifest-resolver.d.ts +59 -0
- package/dist/manifest-resolver.d.ts.map +1 -0
- package/dist/mdx-components.d.ts +51 -3
- package/dist/mdx-components.d.ts.map +1 -1
- package/dist/navigation-utils.d.ts +16 -1
- package/dist/navigation-utils.d.ts.map +1 -1
- package/dist/schema.d.ts +139 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/slug-utils-DUQgikEz.cjs +1 -0
- package/dist/slug-utils-DVKYe9h8.js +31 -0
- package/dist/slug-utils.d.ts +52 -0
- package/dist/slug-utils.d.ts.map +1 -0
- package/dist/types.d.ts +44 -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 +333 -8
- package/docs/mdx-components-reference.md +77 -0
- package/package.json +11 -1
- package/dist/manifest-BJ3t6hu2.js +0 -208
- package/dist/manifest-CNnJGNwK.cjs +0 -3
package/dist/index.js
CHANGED
|
@@ -1,36 +1,233 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var B = (e, t, i) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var m = (e, t, i) => B(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { B as _, D as ee, a as te, b as re, c as ie, F as oe, G as ne, L as se, M as ae, N as le, d as ce, S as fe, V as de, e as he, f as ue, g as ge, h as me, i as ve, j as Fe, k as Ne, v as Se } from "./manifest-B_cvT6F9.js";
|
|
5
|
+
import { e as M } from "./frontmatter-8Bwpoi8r.js";
|
|
6
|
+
import { F as xe, h as be, p as $e, v as we } from "./frontmatter-8Bwpoi8r.js";
|
|
7
|
+
import { s as v, t as F } from "./slug-utils-DVKYe9h8.js";
|
|
8
|
+
import { f as Ee, g as Me, a as Ie } from "./slug-utils-DVKYe9h8.js";
|
|
9
|
+
import { readdirSync as I, readFileSync as P, statSync as T } from "fs";
|
|
10
|
+
import { join as N } from "path";
|
|
11
|
+
const V = (e, t) => e.order !== t.order ? e.order - t.order : e.title.localeCompare(t.title);
|
|
12
|
+
function K(e, t = {}) {
|
|
13
|
+
const { extensions: i = [".mdx", ".md"], filter: r, sort: o = V } = t, n = k(e, i);
|
|
14
|
+
return (r ? n.filter(r) : n).sort(o).map((f) => ({
|
|
15
|
+
title: f.title,
|
|
16
|
+
slug: f.slug,
|
|
17
|
+
file: f.path
|
|
18
|
+
}));
|
|
5
19
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
20
|
+
function O(e, t = {}) {
|
|
21
|
+
return C(e, t, 0);
|
|
22
|
+
}
|
|
23
|
+
function C(e, t, i) {
|
|
24
|
+
const {
|
|
25
|
+
extensions: r = [".mdx", ".md"],
|
|
26
|
+
filter: o,
|
|
27
|
+
sort: n = V,
|
|
28
|
+
maxDepth: a = 1 / 0,
|
|
29
|
+
folderFilter: d
|
|
30
|
+
} = t, f = I(e, { withFileTypes: !0 }), h = [], w = k(e, r), S = (o ? w.filter(o) : w).sort(n);
|
|
31
|
+
for (const c of S)
|
|
32
|
+
h.push({
|
|
33
|
+
title: c.title,
|
|
34
|
+
slug: c.slug,
|
|
35
|
+
file: c.path
|
|
36
|
+
});
|
|
37
|
+
if (i < a) {
|
|
38
|
+
const c = f.filter((l) => l.isDirectory());
|
|
39
|
+
for (const l of c) {
|
|
40
|
+
if (d) {
|
|
41
|
+
const s = N(e, l.name);
|
|
42
|
+
if (!d(l.name, s))
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const u = N(e, l.name), g = C(u, t, i + 1);
|
|
46
|
+
if (g.length > 0) {
|
|
47
|
+
const s = W(u, r);
|
|
48
|
+
h.push({
|
|
49
|
+
title: (s == null ? void 0 : s.title) || F(l.name),
|
|
50
|
+
slug: v(l.name),
|
|
51
|
+
file: s == null ? void 0 : s.path,
|
|
52
|
+
children: g.filter((y) => !(s && y.file === s.path))
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return h.sort((c, l) => {
|
|
58
|
+
var D, E;
|
|
59
|
+
const u = S.find((x) => x.slug === c.slug), g = S.find((x) => x.slug === l.slug);
|
|
60
|
+
if (u && g)
|
|
61
|
+
return n(u, g);
|
|
62
|
+
const s = !!c.file && !((D = c.children) != null && D.length), y = !!l.file && !((E = l.children) != null && E.length);
|
|
63
|
+
return s !== y ? s ? -1 : 1 : (c.title || "").localeCompare(l.title || "");
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function k(e, t) {
|
|
67
|
+
try {
|
|
68
|
+
const i = I(e, { withFileTypes: !0 }), r = [];
|
|
69
|
+
for (const o of i) {
|
|
70
|
+
if (!o.isFile()) continue;
|
|
71
|
+
const n = t.find((h) => o.name.toLowerCase().endsWith(h));
|
|
72
|
+
if (!n || o.name.slice(0, -n.length).toLowerCase() === "index") continue;
|
|
73
|
+
const d = N(e, o.name), f = L(d, o.name, n);
|
|
74
|
+
r.push(f);
|
|
75
|
+
}
|
|
76
|
+
return r;
|
|
77
|
+
} catch {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function L(e, t, i) {
|
|
82
|
+
let r = {}, o = F(t), n = 1 / 0;
|
|
83
|
+
try {
|
|
84
|
+
const a = P(e, "utf-8");
|
|
85
|
+
r = M(a), r.title && typeof r.title == "string" && (o = r.title), typeof r.order == "number" && (n = r.order);
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
path: e,
|
|
90
|
+
filename: t,
|
|
91
|
+
extension: i,
|
|
92
|
+
frontmatter: r,
|
|
93
|
+
order: n,
|
|
94
|
+
title: o,
|
|
95
|
+
slug: v(t)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function W(e, t) {
|
|
99
|
+
for (const i of t) {
|
|
100
|
+
const r = N(e, `index${i}`);
|
|
101
|
+
try {
|
|
102
|
+
if (T(r).isFile())
|
|
103
|
+
return L(r, `index${i}`, i);
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
class b extends Error {
|
|
109
|
+
constructor(i, r, o, n) {
|
|
110
|
+
super(i);
|
|
111
|
+
m(this, "nodePath");
|
|
112
|
+
m(this, "filePath");
|
|
113
|
+
m(this, "originalError");
|
|
114
|
+
this.name = "ManifestResolutionError", this.nodePath = r, this.filePath = o, this.originalError = n;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function Q(e, t = {}) {
|
|
118
|
+
const { strict: i = !0 } = t, r = $(e.navigation, "", i);
|
|
119
|
+
return {
|
|
120
|
+
id: e.id,
|
|
121
|
+
name: e.name,
|
|
122
|
+
version: e.version,
|
|
123
|
+
vendureVersion: e.vendureVersion,
|
|
124
|
+
navigation: r,
|
|
125
|
+
search: e.search,
|
|
126
|
+
github: e.github,
|
|
127
|
+
basePath: e.basePath
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function $(e, t, i) {
|
|
131
|
+
return e.map((r, o) => j(r, t, o, i));
|
|
132
|
+
}
|
|
133
|
+
function j(e, t, i, r) {
|
|
134
|
+
const o = t ? `${t}[${i}]` : `navigation[${i}]`;
|
|
135
|
+
if (e.title && e.slug)
|
|
136
|
+
return {
|
|
137
|
+
title: e.title,
|
|
138
|
+
slug: e.slug,
|
|
139
|
+
file: e.file,
|
|
140
|
+
children: e.children ? $(e.children, `${o}.children`, r) : void 0,
|
|
141
|
+
badge: e.badge,
|
|
142
|
+
hidden: e.hidden
|
|
143
|
+
};
|
|
144
|
+
let n = e.title, a = e.slug;
|
|
145
|
+
if (e.file && (a || (a = v(e.file)), n || (n = p(e.file, o, r))), !n) {
|
|
146
|
+
if (r)
|
|
147
|
+
throw new b(
|
|
148
|
+
`Navigation node at ${o} is missing title and has no file to derive it from`,
|
|
149
|
+
o,
|
|
150
|
+
e.file
|
|
151
|
+
);
|
|
152
|
+
n = a || `Unknown (${i})`;
|
|
153
|
+
}
|
|
154
|
+
if (!a) {
|
|
155
|
+
if (r)
|
|
156
|
+
throw new b(
|
|
157
|
+
`Navigation node at ${o} is missing slug and has no file to derive it from`,
|
|
158
|
+
o,
|
|
159
|
+
e.file
|
|
160
|
+
);
|
|
161
|
+
a = n ? v(n) : `node-${i}`;
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
title: n,
|
|
165
|
+
slug: a,
|
|
166
|
+
file: e.file,
|
|
167
|
+
children: e.children ? $(e.children, `${o}.children`, r) : void 0,
|
|
168
|
+
badge: e.badge,
|
|
169
|
+
hidden: e.hidden
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function p(e, t, i) {
|
|
173
|
+
try {
|
|
174
|
+
const r = P(e, "utf-8"), o = M(r);
|
|
175
|
+
return o.title && typeof o.title == "string" ? o.title : F(e);
|
|
176
|
+
} catch (r) {
|
|
177
|
+
if (i)
|
|
178
|
+
throw new b(
|
|
179
|
+
`Failed to read file for title derivation at ${t}: ${e}`,
|
|
180
|
+
t,
|
|
181
|
+
e,
|
|
182
|
+
r
|
|
183
|
+
);
|
|
184
|
+
return F(e);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function X(e) {
|
|
188
|
+
return R(e.navigation);
|
|
189
|
+
}
|
|
190
|
+
function R(e) {
|
|
191
|
+
for (const t of e)
|
|
192
|
+
if (!t.title || !t.slug || t.children && R(t.children))
|
|
193
|
+
return !0;
|
|
194
|
+
return !1;
|
|
9
195
|
}
|
|
10
196
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
M as
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
197
|
+
_ as BreadcrumbItemSchema,
|
|
198
|
+
ee as DocPageMetaSchema,
|
|
199
|
+
te as DocPageSchema,
|
|
200
|
+
re as DocsPackageManifestInputSchema,
|
|
201
|
+
ie as DocsPackageManifestSchema,
|
|
202
|
+
oe as FlatNavigationNodeSchema,
|
|
203
|
+
xe as FrontmatterParseError,
|
|
204
|
+
ne as GitHubConfigSchema,
|
|
205
|
+
se as LoadedDocsPackageSchema,
|
|
206
|
+
b as ManifestResolutionError,
|
|
207
|
+
ae as ManifestValidationError,
|
|
208
|
+
le as NavigationNodeInputSchema,
|
|
209
|
+
ce as NavigationNodeSchema,
|
|
210
|
+
fe as SearchConfigSchema,
|
|
211
|
+
de as VendureVersionSchema,
|
|
212
|
+
he as buildBreadcrumbs,
|
|
213
|
+
K as createNavigationFromFolder,
|
|
214
|
+
O as createNestedNavigationFromFolder,
|
|
215
|
+
M as extractFrontmatterData,
|
|
216
|
+
Ee as filterVisibleNavigation,
|
|
217
|
+
ue as findNavigationNode,
|
|
218
|
+
ge as flattenNavigation,
|
|
219
|
+
Me as getAllFilePaths,
|
|
220
|
+
me as getLeafNodes,
|
|
221
|
+
ve as getNodesAtDepth,
|
|
222
|
+
Fe as getPrevNextNodes,
|
|
223
|
+
be as hasFrontmatter,
|
|
224
|
+
Ne as isNodeActive,
|
|
225
|
+
X as manifestNeedsResolution,
|
|
226
|
+
$e as parseFrontmatter,
|
|
227
|
+
Q as resolveManifest,
|
|
228
|
+
v as slugFromFilename,
|
|
229
|
+
F as titleFromFilename,
|
|
230
|
+
Ie as toSlug,
|
|
231
|
+
we as validateFrontmatter,
|
|
232
|
+
Se as validateManifest
|
|
36
233
|
};
|
package/dist/loader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var g=(e,r,t)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r,t)=>g(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("fs/promises"),P=require("module"),m=require("./frontmatter-_wRoVeyd.cjs"),p=require("./manifest-D8kEDc9X.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 $(e,r={}){try{const t=r.resolver?await r.resolver(e):u(e),n=await import(e);if(!n.manifest)throw new a(`Package "${e}" does not export a manifest`,e);return{manifest:p.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 u(e){try{return P.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 l(e,r){try{const t=`${e.basePath}/${r}`,n=await h.readFile(t,"utf-8"),{meta:o,content:s}=m.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 v(e,r){const t=d(e.manifest.navigation,r.split("/"));if(t!=null&&t.file)return l(e,t.file)}function d(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 d(o.children,n)}}function y(e,r){if(r.file)return`${e.basePath}/${r.file}`}function w(e){try{return u(e),!0}catch{return!1}}exports.DocsPackageLoadError=a;exports.isDocsPackageInstalled=w;exports.loadDocPage=l;exports.loadDocPageBySlug=v;exports.loadDocsPackage=$;exports.resolveFilePath=y;
|
package/dist/loader.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var l = (t, e, r) => e in t ?
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var l = (t, e, r) => e in t ? u(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
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 { p as g } from "./frontmatter-8Bwpoi8r.js";
|
|
7
|
+
import { v as m } from "./manifest-B_cvT6F9.js";
|
|
7
8
|
class a extends Error {
|
|
8
9
|
constructor(r, n) {
|
|
9
10
|
super(r);
|
|
@@ -11,7 +12,7 @@ class a extends Error {
|
|
|
11
12
|
this.name = "DocsPackageLoadError", this.packageName = n;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
async function
|
|
15
|
+
async function k(t, e = {}) {
|
|
15
16
|
try {
|
|
16
17
|
const r = e.resolver ? await e.resolver(t) : c(t), n = await import(t);
|
|
17
18
|
if (!n.manifest)
|
|
@@ -20,7 +21,7 @@ async function y(t, e = {}) {
|
|
|
20
21
|
t
|
|
21
22
|
);
|
|
22
23
|
return {
|
|
23
|
-
manifest:
|
|
24
|
+
manifest: m(n.manifest),
|
|
24
25
|
basePath: r
|
|
25
26
|
};
|
|
26
27
|
} catch (r) {
|
|
@@ -42,7 +43,7 @@ function c(t) {
|
|
|
42
43
|
}
|
|
43
44
|
async function p(t, e) {
|
|
44
45
|
try {
|
|
45
|
-
const r = `${t.basePath}/${e}`, n = await d(r, "utf-8"), { meta: o, content: s } =
|
|
46
|
+
const r = `${t.basePath}/${e}`, n = await d(r, "utf-8"), { meta: o, content: s } = g(n, e);
|
|
46
47
|
return {
|
|
47
48
|
meta: o,
|
|
48
49
|
content: s,
|
|
@@ -55,25 +56,25 @@ async function p(t, e) {
|
|
|
55
56
|
);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
async function
|
|
59
|
-
const r =
|
|
59
|
+
async function D(t, e) {
|
|
60
|
+
const r = f(t.manifest.navigation, e.split("/"));
|
|
60
61
|
if (r != null && r.file)
|
|
61
62
|
return p(t, r.file);
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
+
function f(t, e) {
|
|
64
65
|
if (e.length === 0) return;
|
|
65
66
|
const [r, ...n] = e, o = t.find((s) => s.slug === r);
|
|
66
67
|
if (o) {
|
|
67
68
|
if (n.length === 0) return o;
|
|
68
69
|
if (o.children)
|
|
69
|
-
return
|
|
70
|
+
return f(o.children, n);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
+
function E(t, e) {
|
|
73
74
|
if (e.file)
|
|
74
75
|
return `${t.basePath}/${e.file}`;
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
+
function F(t) {
|
|
77
78
|
try {
|
|
78
79
|
return c(t), !0;
|
|
79
80
|
} catch {
|
|
@@ -82,9 +83,9 @@ function E(t) {
|
|
|
82
83
|
}
|
|
83
84
|
export {
|
|
84
85
|
a as DocsPackageLoadError,
|
|
85
|
-
|
|
86
|
+
F as isDocsPackageInstalled,
|
|
86
87
|
p as loadDocPage,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
D as loadDocPageBySlug,
|
|
89
|
+
k as loadDocsPackage,
|
|
90
|
+
E as resolveFilePath
|
|
90
91
|
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var S = (i, t, e) => t in i ? P(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var g = (i, t, e) => S(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { z as n } from "zod";
|
|
5
|
+
const d = n.enum(["v1", "v2", "v3"]), u = n.object({
|
|
6
|
+
indexFields: n.array(n.enum(["title", "description", "content", "keywords"])),
|
|
7
|
+
boosts: n.record(n.string(), n.number()).optional()
|
|
8
|
+
}), h = n.object({
|
|
9
|
+
repository: n.string().regex(/^[^/]+\/[^/]+$/, 'Repository must be in format "owner/repo"'),
|
|
10
|
+
branch: n.string().optional(),
|
|
11
|
+
docsPath: n.string().optional()
|
|
12
|
+
}), c = n.lazy(
|
|
13
|
+
() => n.object({
|
|
14
|
+
title: n.string().min(1, "Navigation title is required"),
|
|
15
|
+
slug: n.string().min(1, "Navigation slug is required"),
|
|
16
|
+
file: n.string().optional(),
|
|
17
|
+
children: n.array(c).optional(),
|
|
18
|
+
badge: n.string().optional(),
|
|
19
|
+
hidden: n.boolean().optional()
|
|
20
|
+
})
|
|
21
|
+
), f = n.object({
|
|
22
|
+
id: n.string().min(1, "Package ID is required"),
|
|
23
|
+
name: n.string().min(1, "Package name is required"),
|
|
24
|
+
version: n.string().regex(/^\d+\.\d+\.\d+/, "Version must be valid semver"),
|
|
25
|
+
vendureVersion: d,
|
|
26
|
+
navigation: n.array(c),
|
|
27
|
+
search: u.optional(),
|
|
28
|
+
github: h.optional(),
|
|
29
|
+
basePath: n.string().optional()
|
|
30
|
+
}), y = n.object({
|
|
31
|
+
title: n.string().min(1, "Page title is required"),
|
|
32
|
+
description: n.string().optional(),
|
|
33
|
+
keywords: n.array(n.string()).optional(),
|
|
34
|
+
sidebarLabel: n.string().optional(),
|
|
35
|
+
hidden: n.boolean().optional(),
|
|
36
|
+
order: n.number().int().optional()
|
|
37
|
+
}), I = n.object({
|
|
38
|
+
meta: y,
|
|
39
|
+
content: n.string(),
|
|
40
|
+
filePath: n.string()
|
|
41
|
+
}), q = n.object({
|
|
42
|
+
manifest: f,
|
|
43
|
+
basePath: n.string()
|
|
44
|
+
}), B = n.object({
|
|
45
|
+
title: n.string(),
|
|
46
|
+
slug: n.string(),
|
|
47
|
+
path: n.string()
|
|
48
|
+
}), M = n.object({
|
|
49
|
+
title: n.string(),
|
|
50
|
+
slug: n.string(),
|
|
51
|
+
file: n.string().optional(),
|
|
52
|
+
children: n.array(n.lazy(() => c)).optional(),
|
|
53
|
+
badge: n.string().optional(),
|
|
54
|
+
hidden: n.boolean().optional(),
|
|
55
|
+
path: n.string(),
|
|
56
|
+
depth: n.number().int().min(0),
|
|
57
|
+
parentPath: n.string().optional()
|
|
58
|
+
}), m = n.lazy(
|
|
59
|
+
() => n.object({
|
|
60
|
+
title: n.string().min(1).optional(),
|
|
61
|
+
slug: n.string().min(1).optional(),
|
|
62
|
+
file: n.string().optional(),
|
|
63
|
+
children: n.array(m).optional(),
|
|
64
|
+
badge: n.string().optional(),
|
|
65
|
+
hidden: n.boolean().optional()
|
|
66
|
+
})
|
|
67
|
+
), $ = n.object({
|
|
68
|
+
id: n.string().min(1, "Package ID is required"),
|
|
69
|
+
name: n.string().min(1, "Package name is required"),
|
|
70
|
+
version: n.string().regex(/^\d+\.\d+\.\d+/, "Version must be valid semver"),
|
|
71
|
+
vendureVersion: d,
|
|
72
|
+
navigation: n.array(m),
|
|
73
|
+
search: u.optional(),
|
|
74
|
+
github: h.optional(),
|
|
75
|
+
basePath: n.string().optional()
|
|
76
|
+
});
|
|
77
|
+
class j extends Error {
|
|
78
|
+
constructor(e, o) {
|
|
79
|
+
super(e);
|
|
80
|
+
g(this, "issues");
|
|
81
|
+
this.name = "ManifestValidationError", this.issues = o;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function w(i) {
|
|
85
|
+
const t = f.safeParse(i);
|
|
86
|
+
if (!t.success) {
|
|
87
|
+
const e = t.error.issues.map((o) => `${o.path.join(".")}: ${o.message}`);
|
|
88
|
+
throw new j("Invalid manifest", e);
|
|
89
|
+
}
|
|
90
|
+
return t.data;
|
|
91
|
+
}
|
|
92
|
+
function z(i, t) {
|
|
93
|
+
const e = t.split("/").filter(Boolean);
|
|
94
|
+
return p(i.navigation, e);
|
|
95
|
+
}
|
|
96
|
+
function p(i, t) {
|
|
97
|
+
if (t.length === 0) return;
|
|
98
|
+
const [e, ...o] = t, a = i.find((r) => r.slug === e);
|
|
99
|
+
if (a) {
|
|
100
|
+
if (o.length === 0) return a;
|
|
101
|
+
if (a.children)
|
|
102
|
+
return p(a.children, o);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function b(i) {
|
|
106
|
+
const t = [];
|
|
107
|
+
return v(i.navigation, "", 0, void 0, t), t;
|
|
108
|
+
}
|
|
109
|
+
function v(i, t, e, o, a) {
|
|
110
|
+
for (const r of i) {
|
|
111
|
+
const s = t ? `${t}/${r.slug}` : r.slug;
|
|
112
|
+
a.push({
|
|
113
|
+
...r,
|
|
114
|
+
path: s,
|
|
115
|
+
depth: e,
|
|
116
|
+
parentPath: o
|
|
117
|
+
}), r.children && r.children.length > 0 && v(r.children, s, e + 1, s, a);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function L(i, t) {
|
|
121
|
+
const e = t.split("/").filter(Boolean), o = [];
|
|
122
|
+
let a = i.navigation, r = "";
|
|
123
|
+
for (const s of e) {
|
|
124
|
+
const l = a.find((N) => N.slug === s);
|
|
125
|
+
if (!l) break;
|
|
126
|
+
r = r ? `${r}/${s}` : s, o.push({
|
|
127
|
+
title: l.title,
|
|
128
|
+
slug: l.slug,
|
|
129
|
+
path: r
|
|
130
|
+
}), a = l.children ?? [];
|
|
131
|
+
}
|
|
132
|
+
return o;
|
|
133
|
+
}
|
|
134
|
+
function k(i) {
|
|
135
|
+
return b(i).filter((t) => t.file !== void 0);
|
|
136
|
+
}
|
|
137
|
+
function E(i, t) {
|
|
138
|
+
const e = k(i), o = e.findIndex((a) => a.path === t);
|
|
139
|
+
return o === -1 ? {} : {
|
|
140
|
+
prev: o > 0 ? e[o - 1] : void 0,
|
|
141
|
+
next: o < e.length - 1 ? e[o + 1] : void 0
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function x(i, t) {
|
|
145
|
+
const e = t.split("/").filter(Boolean);
|
|
146
|
+
if (e.length === 0) return !1;
|
|
147
|
+
if (i.slug === e[0]) {
|
|
148
|
+
if (e.length === 1) return !0;
|
|
149
|
+
if (i.children) {
|
|
150
|
+
const o = e.slice(1).join("/");
|
|
151
|
+
return i.children.some((a) => x(a, o));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return !1;
|
|
155
|
+
}
|
|
156
|
+
function F(i, t) {
|
|
157
|
+
return b(i).filter((e) => e.depth === t);
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
B,
|
|
161
|
+
y as D,
|
|
162
|
+
M as F,
|
|
163
|
+
h as G,
|
|
164
|
+
q as L,
|
|
165
|
+
j as M,
|
|
166
|
+
m as N,
|
|
167
|
+
u as S,
|
|
168
|
+
d as V,
|
|
169
|
+
I as a,
|
|
170
|
+
$ as b,
|
|
171
|
+
f as c,
|
|
172
|
+
c as d,
|
|
173
|
+
L as e,
|
|
174
|
+
z as f,
|
|
175
|
+
b as g,
|
|
176
|
+
k as h,
|
|
177
|
+
F as i,
|
|
178
|
+
E as j,
|
|
179
|
+
x as k,
|
|
180
|
+
w as v
|
|
181
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var D=Object.defineProperty;var j=(i,t,n)=>t in i?D(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var f=(i,t,n)=>j(i,typeof t!="symbol"?t+"":t,n);const e=require("zod"),g=e.z.enum(["v1","v2","v3"]),d=e.z.object({indexFields:e.z.array(e.z.enum(["title","description","content","keywords"])),boosts:e.z.record(e.z.string(),e.z.number()).optional()}),u=e.z.object({repository:e.z.string().regex(/^[^/]+\/[^/]+$/,'Repository must be in format "owner/repo"'),branch:e.z.string().optional(),docsPath:e.z.string().optional()}),l=e.z.lazy(()=>e.z.object({title:e.z.string().min(1,"Navigation title is required"),slug:e.z.string().min(1,"Navigation slug is required"),file:e.z.string().optional(),children:e.z.array(l).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional()})),h=e.z.object({id:e.z.string().min(1,"Package ID is required"),name:e.z.string().min(1,"Package name is required"),version:e.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:g,navigation:e.z.array(l),search:d.optional(),github:u.optional(),basePath:e.z.string().optional()}),p=e.z.object({title:e.z.string().min(1,"Page title is required"),description:e.z.string().optional(),keywords:e.z.array(e.z.string()).optional(),sidebarLabel:e.z.string().optional(),hidden:e.z.boolean().optional(),order:e.z.number().int().optional()}),k=e.z.object({meta:p,content:e.z.string(),filePath:e.z.string()}),I=e.z.object({manifest:h,basePath:e.z.string()}),M=e.z.object({title:e.z.string(),slug:e.z.string(),path:e.z.string()}),V=e.z.object({title:e.z.string(),slug:e.z.string(),file:e.z.string().optional(),children:e.z.array(e.z.lazy(()=>l)).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional(),path:e.z.string(),depth:e.z.number().int().min(0),parentPath:e.z.string().optional()}),z=e.z.lazy(()=>e.z.object({title:e.z.string().min(1).optional(),slug:e.z.string().min(1).optional(),file:e.z.string().optional(),children:e.z.array(z).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional()})),x=e.z.object({id:e.z.string().min(1,"Package ID is required"),name:e.z.string().min(1,"Package name is required"),version:e.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:g,navigation:e.z.array(z),search:d.optional(),github:u.optional(),basePath:e.z.string().optional()});class b extends Error{constructor(n,o){super(n);f(this,"issues");this.name="ManifestValidationError",this.issues=o}}function q(i){const t=h.safeParse(i);if(!t.success){const n=t.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`);throw new b("Invalid manifest",n)}return t.data}function B(i,t){const n=t.split("/").filter(Boolean);return v(i.navigation,n)}function v(i,t){if(t.length===0)return;const[n,...o]=t,a=i.find(r=>r.slug===n);if(a){if(o.length===0)return a;if(a.children)return v(a.children,o)}}function m(i){const t=[];return N(i.navigation,"",0,void 0,t),t}function N(i,t,n,o,a){for(const r of i){const s=t?`${t}/${r.slug}`:r.slug;a.push({...r,path:s,depth:n,parentPath:o}),r.children&&r.children.length>0&&N(r.children,s,n+1,s,a)}}function $(i,t){const n=t.split("/").filter(Boolean),o=[];let a=i.navigation,r="";for(const s of n){const c=a.find(y=>y.slug===s);if(!c)break;r=r?`${r}/${s}`:s,o.push({title:c.title,slug:c.slug,path:r}),a=c.children??[]}return o}function S(i){return m(i).filter(t=>t.file!==void 0)}function w(i,t){const n=S(i),o=n.findIndex(a=>a.path===t);return o===-1?{}:{prev:o>0?n[o-1]:void 0,next:o<n.length-1?n[o+1]:void 0}}function P(i,t){const n=t.split("/").filter(Boolean);if(n.length===0)return!1;if(i.slug===n[0]){if(n.length===1)return!0;if(i.children){const o=n.slice(1).join("/");return i.children.some(a=>P(a,o))}}return!1}function L(i,t){return m(i).filter(n=>n.depth===t)}exports.BreadcrumbItemSchema=M;exports.DocPageMetaSchema=p;exports.DocPageSchema=k;exports.DocsPackageManifestInputSchema=x;exports.DocsPackageManifestSchema=h;exports.FlatNavigationNodeSchema=V;exports.GitHubConfigSchema=u;exports.LoadedDocsPackageSchema=I;exports.ManifestValidationError=b;exports.NavigationNodeInputSchema=z;exports.NavigationNodeSchema=l;exports.SearchConfigSchema=d;exports.VendureVersionSchema=g;exports.buildBreadcrumbs=$;exports.findNavigationNode=B;exports.flattenNavigation=m;exports.getLeafNodes=S;exports.getNodesAtDepth=L;exports.getPrevNextNodes=w;exports.isNodeActive=P;exports.validateManifest=q;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DocsPackageManifest, DocsPackageManifestInput } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when manifest resolution fails
|
|
4
|
+
*/
|
|
5
|
+
export declare class ManifestResolutionError extends Error {
|
|
6
|
+
readonly nodePath?: string;
|
|
7
|
+
readonly filePath?: string;
|
|
8
|
+
readonly originalError?: unknown;
|
|
9
|
+
constructor(message: string, nodePath?: string, filePath?: string, originalError?: unknown);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Options for manifest resolution
|
|
13
|
+
*/
|
|
14
|
+
export interface ResolveManifestOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Whether to throw an error if a file cannot be read.
|
|
17
|
+
* If false, nodes without valid files will use filename-derived values.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
strict?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a manifest input by deriving missing title/slug values from files.
|
|
24
|
+
*
|
|
25
|
+
* For navigation nodes:
|
|
26
|
+
* - If `title` is missing, reads from frontmatter `title` or derives from filename
|
|
27
|
+
* - If `slug` is missing, derives from filename
|
|
28
|
+
*
|
|
29
|
+
* @param input - The manifest input with optional title/slug
|
|
30
|
+
* @param options - Resolution options
|
|
31
|
+
* @returns Fully resolved DocsPackageManifest
|
|
32
|
+
* @throws {ManifestResolutionError} If resolution fails (in strict mode)
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const input: DocsPackageManifestInput = {
|
|
37
|
+
* id: 'my-docs',
|
|
38
|
+
* name: 'My Docs',
|
|
39
|
+
* version: '1.0.0',
|
|
40
|
+
* vendureVersion: 'v3',
|
|
41
|
+
* navigation: [
|
|
42
|
+
* { file: file('docs/getting-started.mdx') }, // title & slug derived
|
|
43
|
+
* { title: 'Custom Title', file: file('docs/intro.mdx') }, // only slug derived
|
|
44
|
+
* ],
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* const manifest = resolveManifest(input)
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveManifest(input: DocsPackageManifestInput, options?: ResolveManifestOptions): DocsPackageManifest;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a manifest input needs resolution
|
|
53
|
+
* (i.e., has any navigation nodes with missing title or slug)
|
|
54
|
+
*
|
|
55
|
+
* @param input - The manifest input to check
|
|
56
|
+
* @returns True if resolution is needed
|
|
57
|
+
*/
|
|
58
|
+
export declare function manifestNeedsResolution(input: DocsPackageManifestInput): boolean;
|
|
59
|
+
//# sourceMappingURL=manifest-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-resolver.d.ts","sourceRoot":"","sources":["../src/manifest-resolver.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EAGzB,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjC,SAAgB,aAAa,CAAC,EAAE,OAAO,CAAA;gBAE3B,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO;CAO3F;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,wBAAwB,EAC/B,OAAO,GAAE,sBAA2B,GACnC,mBAAmB,CAerB;AAwHD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAEhF"}
|
package/dist/mdx-components.d.ts
CHANGED
|
@@ -51,8 +51,8 @@ export interface GenerationInfoProps {
|
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
53
|
export interface MemberInfoProps {
|
|
54
|
-
/** Member kind: method, property, getter, setter, constructor */
|
|
55
|
-
kind: 'method' | 'property' | 'getter' | 'setter' | 'constructor';
|
|
54
|
+
/** Member kind: method, property, getter, setter, constructor, parameter */
|
|
55
|
+
kind: 'method' | 'property' | 'getter' | 'setter' | 'constructor' | 'parameter';
|
|
56
56
|
/** TypeScript type signature (accepts JSX with links) */
|
|
57
57
|
type: unknown;
|
|
58
58
|
/** Version when this member was introduced */
|
|
@@ -153,8 +153,56 @@ export interface GraphQLDocProps {
|
|
|
153
153
|
/** GraphQL SDL content */
|
|
154
154
|
children: unknown;
|
|
155
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* LinkCard Component
|
|
158
|
+
*
|
|
159
|
+
* A card-style link that provides more visual prominence than a standard link.
|
|
160
|
+
* Displays a title, optional subtitle, and an arrow indicator.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```mdx
|
|
164
|
+
* <LinkCard
|
|
165
|
+
* href="/guides/getting-started"
|
|
166
|
+
* title="Getting Started"
|
|
167
|
+
* subtitle="Learn how to set up your first project"
|
|
168
|
+
* />
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export interface LinkCardProps {
|
|
172
|
+
/** URL to navigate to (internal or external) */
|
|
173
|
+
href: string;
|
|
174
|
+
/** Primary text displayed on the card */
|
|
175
|
+
title: string;
|
|
176
|
+
/** Secondary text displayed below the title */
|
|
177
|
+
subtitle?: string;
|
|
178
|
+
/** Additional content (alternative to subtitle for richer content) */
|
|
179
|
+
children?: unknown;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* DocsLink Component
|
|
183
|
+
*
|
|
184
|
+
* An inline link component that automatically prefixes relative URLs with the
|
|
185
|
+
* current documentation version and package ID. This is the recommended way to
|
|
186
|
+
* create cross-references in generated documentation.
|
|
187
|
+
*
|
|
188
|
+
* Key features:
|
|
189
|
+
* - Relative paths (starting with `/`) are automatically prefixed with `/{version}/{packageId}`
|
|
190
|
+
* - Uses Next.js Link for client-side navigation (no full page reload)
|
|
191
|
+
* - External links open in a new tab
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```mdx
|
|
195
|
+
* See the <DocsLink href="/reference/typescript-api/request/request-context">RequestContext</DocsLink> docs.
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export interface DocsLinkProps {
|
|
199
|
+
/** URL to navigate to (relative paths will be prefixed with version/packageId) */
|
|
200
|
+
href: string;
|
|
201
|
+
/** Link text content */
|
|
202
|
+
children: unknown;
|
|
203
|
+
}
|
|
156
204
|
/**
|
|
157
205
|
* Union type of all MDX component props for type checking
|
|
158
206
|
*/
|
|
159
|
-
export type MdxComponentProps = GenerationInfoProps | MemberInfoProps | MemberDescriptionProps | CustomFieldPropertyProps | StackblitzProps | GraphQLDocProps;
|
|
207
|
+
export type MdxComponentProps = GenerationInfoProps | MemberInfoProps | MemberDescriptionProps | CustomFieldPropertyProps | StackblitzProps | GraphQLDocProps | LinkCardProps | DocsLinkProps;
|
|
160
208
|
//# sourceMappingURL=mdx-components.d.ts.map
|