@lexibase/rdx-core 2.0.0 → 2.2.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/dist/check/index.js +109 -32
- package/dist/{chunk-FWPJPY46.js → chunk-36CTLWNI.js} +15 -4
- package/dist/chunk-GYLAW7YX.js +947 -0
- package/dist/{chunk-MALRN4SS.js → chunk-M32EH5KP.js} +113 -18
- package/dist/chunk-SNNEXRLQ.js +75 -0
- package/dist/config/index.d.ts +2 -16
- package/dist/config/index.js +9 -1
- package/dist/{document-links-CkvFGpe1.d.ts → document-links-B9zsPsqx.d.ts} +4 -1
- package/dist/index-DjuvW7o_.d.ts +49 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +20 -8
- package/dist/mdx/index.d.ts +1 -1
- package/dist/mdx/index.js +1 -1
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.js +3 -1
- package/package.json +4 -4
- package/dist/chunk-6GMOZSPH.js +0 -459
|
@@ -16,7 +16,8 @@ function parseStaticDocument(source) {
|
|
|
16
16
|
import fs from "fs";
|
|
17
17
|
import path from "path";
|
|
18
18
|
import matter2 from "gray-matter";
|
|
19
|
-
var
|
|
19
|
+
var DOCUMENT_EXTENSIONS = [".md", ".mdx"];
|
|
20
|
+
var documentExtension = /\.mdx?$/;
|
|
20
21
|
var DEFAULT_POSITION = Number.MAX_SAFE_INTEGER;
|
|
21
22
|
function getDocsRoot(docsDir = "docs") {
|
|
22
23
|
return path.resolve(
|
|
@@ -39,11 +40,20 @@ function numberValue(value, fallback = DEFAULT_POSITION) {
|
|
|
39
40
|
}
|
|
40
41
|
function readCategoryMeta(categoryPath, fallbackTitle) {
|
|
41
42
|
const metaPath = path.join(categoryPath, "_category.json");
|
|
42
|
-
if (!fs.existsSync(
|
|
43
|
+
if (!fs.existsSync(
|
|
44
|
+
/* turbopackIgnore: true */
|
|
45
|
+
metaPath
|
|
46
|
+
)) {
|
|
43
47
|
return { title: fallbackTitle, position: DEFAULT_POSITION };
|
|
44
48
|
}
|
|
45
49
|
try {
|
|
46
|
-
const parsed = JSON.parse(
|
|
50
|
+
const parsed = JSON.parse(
|
|
51
|
+
fs.readFileSync(
|
|
52
|
+
/* turbopackIgnore: true */
|
|
53
|
+
metaPath,
|
|
54
|
+
"utf8"
|
|
55
|
+
)
|
|
56
|
+
);
|
|
47
57
|
if (!isRecord(parsed)) {
|
|
48
58
|
return { title: fallbackTitle, position: DEFAULT_POSITION };
|
|
49
59
|
}
|
|
@@ -55,27 +65,71 @@ function readCategoryMeta(categoryPath, fallbackTitle) {
|
|
|
55
65
|
return { title: fallbackTitle, position: DEFAULT_POSITION };
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
|
-
function
|
|
59
|
-
const entries = fs.readdirSync(
|
|
68
|
+
function findDocumentFiles(directory) {
|
|
69
|
+
const entries = fs.readdirSync(
|
|
70
|
+
/* turbopackIgnore: true */
|
|
71
|
+
directory,
|
|
72
|
+
{ withFileTypes: true }
|
|
73
|
+
).sort((a, b) => a.name.localeCompare(b.name));
|
|
60
74
|
return entries.flatMap((entry) => {
|
|
61
75
|
const entryPath = path.join(directory, entry.name);
|
|
62
|
-
if (entry.isDirectory()) return
|
|
63
|
-
if (entry.isFile() && entry.name
|
|
76
|
+
if (entry.isDirectory()) return findDocumentFiles(entryPath);
|
|
77
|
+
if (entry.isFile() && documentExtension.test(entry.name)) return [entryPath];
|
|
64
78
|
return [];
|
|
65
79
|
});
|
|
66
80
|
}
|
|
67
81
|
function slugFromRelativePath(relativePath) {
|
|
68
|
-
return relativePath.split(path.sep).join("/").replace(
|
|
82
|
+
return relativePath.split(path.sep).join("/").replace(documentExtension, "");
|
|
69
83
|
}
|
|
70
84
|
function isSafeSlug(slug) {
|
|
71
85
|
if (path.isAbsolute(slug) || slug.includes("\\")) return false;
|
|
72
86
|
return slug.split("/").every((segment) => segment && segment !== "." && segment !== "..");
|
|
73
87
|
}
|
|
74
|
-
function getDocsIndex({ docsDir } = {}, onError) {
|
|
88
|
+
function getDocsIndex({ docsDir, fallbackDocsDir, fallbackOnly } = {}, onError) {
|
|
89
|
+
if (fallbackOnly)
|
|
90
|
+
return getDocsIndex({ docsDir: fallbackDocsDir ?? docsDir }, onError);
|
|
91
|
+
if (fallbackDocsDir) {
|
|
92
|
+
const primary = getDocsIndex({ docsDir: fallbackDocsDir }, onError);
|
|
93
|
+
const translated = getDocsIndex({ docsDir }, onError);
|
|
94
|
+
const pages = new Map(
|
|
95
|
+
translated.flatMap(
|
|
96
|
+
(category) => category.pages.map((page) => [page.slug, page])
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
return primary.map((category) => ({
|
|
100
|
+
...category,
|
|
101
|
+
title: readCategoryMeta(
|
|
102
|
+
path.join(
|
|
103
|
+
getDocsRoot(docsDir),
|
|
104
|
+
category.id === "_root" ? "" : category.id
|
|
105
|
+
),
|
|
106
|
+
category.title
|
|
107
|
+
).title,
|
|
108
|
+
pages: category.pages.map((page) => ({
|
|
109
|
+
...pages.get(page.slug) ?? page,
|
|
110
|
+
position: page.position
|
|
111
|
+
}))
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
75
114
|
const docsRoot = getDocsRoot(docsDir);
|
|
76
|
-
if (!fs.existsSync(
|
|
115
|
+
if (!fs.existsSync(
|
|
116
|
+
/* turbopackIgnore: true */
|
|
117
|
+
docsRoot
|
|
118
|
+
)) return [];
|
|
77
119
|
const categories = /* @__PURE__ */ new Map();
|
|
78
|
-
|
|
120
|
+
const slugs = /* @__PURE__ */ new Map();
|
|
121
|
+
for (const filePath of findDocumentFiles(docsRoot)) {
|
|
122
|
+
const slug = slugFromRelativePath(path.relative(docsRoot, filePath));
|
|
123
|
+
const previous = slugs.get(slug);
|
|
124
|
+
if (previous) {
|
|
125
|
+
const error = new Error(
|
|
126
|
+
`[RDX] Duplicate documentation route "${slug}": ${previous} and ${filePath}. Keep one page per route.`
|
|
127
|
+
);
|
|
128
|
+
if (!onError) throw error;
|
|
129
|
+
onError(error, filePath);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
slugs.set(slug, filePath);
|
|
79
133
|
const relativePath = path.relative(docsRoot, filePath);
|
|
80
134
|
const pathParts = relativePath.split(path.sep);
|
|
81
135
|
const categoryId = pathParts.length > 1 ? pathParts[0] ?? "_root" : "_root";
|
|
@@ -96,14 +150,17 @@ function getDocsIndex({ docsDir } = {}, onError) {
|
|
|
96
150
|
}
|
|
97
151
|
let frontmatter = {};
|
|
98
152
|
try {
|
|
99
|
-
const raw = fs.readFileSync(
|
|
153
|
+
const raw = fs.readFileSync(
|
|
154
|
+
/* turbopackIgnore: true */
|
|
155
|
+
filePath,
|
|
156
|
+
"utf8"
|
|
157
|
+
);
|
|
100
158
|
const parsed = onError ? parseStaticDocument(raw) : matter2(raw);
|
|
101
159
|
frontmatter = isRecord(parsed.data) ? parsed.data : {};
|
|
102
160
|
} catch (error) {
|
|
103
161
|
if (!onError) throw error;
|
|
104
162
|
onError(error, filePath);
|
|
105
163
|
}
|
|
106
|
-
const slug = slugFromRelativePath(relativePath);
|
|
107
164
|
const fallbackTitle = toTitle(path.basename(slug));
|
|
108
165
|
category.pages.push({
|
|
109
166
|
slug,
|
|
@@ -127,15 +184,44 @@ function getDocsPaths(options) {
|
|
|
127
184
|
(category) => category.pages.map((page) => page.slug)
|
|
128
185
|
);
|
|
129
186
|
}
|
|
130
|
-
function getDocument(slug, { docsDir } = {}) {
|
|
187
|
+
function getDocument(slug, { docsDir, fallbackDocsDir, fallbackOnly } = {}) {
|
|
131
188
|
if (!isSafeSlug(slug)) return null;
|
|
189
|
+
if (fallbackOnly)
|
|
190
|
+
return getDocument(slug, { docsDir: fallbackDocsDir ?? docsDir });
|
|
132
191
|
const docsRoot = getDocsRoot(docsDir);
|
|
133
|
-
const
|
|
192
|
+
const candidates = DOCUMENT_EXTENSIONS.map(
|
|
193
|
+
(extension) => path.resolve(docsRoot, `${slug}${extension}`)
|
|
194
|
+
).filter(
|
|
195
|
+
(filename) => fs.existsSync(
|
|
196
|
+
/* turbopackIgnore: true */
|
|
197
|
+
filename
|
|
198
|
+
) && fs.statSync(
|
|
199
|
+
/* turbopackIgnore: true */
|
|
200
|
+
filename
|
|
201
|
+
).isFile()
|
|
202
|
+
);
|
|
203
|
+
if (candidates.length > 1)
|
|
204
|
+
throw new Error(
|
|
205
|
+
`[RDX] Duplicate documentation route "${slug}": ${candidates.join(" and ")}. Keep one page per route.`
|
|
206
|
+
);
|
|
207
|
+
const sourcePath = candidates[0] ?? path.resolve(docsRoot, `${slug}.mdx`);
|
|
134
208
|
const relativePath = path.relative(docsRoot, sourcePath);
|
|
135
209
|
if (relativePath.startsWith("..") || path.isAbsolute(relativePath))
|
|
136
210
|
return null;
|
|
137
|
-
if (!
|
|
138
|
-
|
|
211
|
+
if (fallbackDocsDir && !getDocument(slug, { docsDir: fallbackDocsDir }))
|
|
212
|
+
return null;
|
|
213
|
+
if (!fs.existsSync(
|
|
214
|
+
/* turbopackIgnore: true */
|
|
215
|
+
sourcePath
|
|
216
|
+
))
|
|
217
|
+
return fallbackDocsDir ? getDocument(slug, { docsDir: fallbackDocsDir }) : null;
|
|
218
|
+
const parsed = matter2(
|
|
219
|
+
fs.readFileSync(
|
|
220
|
+
/* turbopackIgnore: true */
|
|
221
|
+
sourcePath,
|
|
222
|
+
"utf8"
|
|
223
|
+
)
|
|
224
|
+
);
|
|
139
225
|
return {
|
|
140
226
|
slug,
|
|
141
227
|
sourcePath,
|
|
@@ -147,7 +233,16 @@ function getDocument(slug, { docsDir } = {}) {
|
|
|
147
233
|
// src/project/index.ts
|
|
148
234
|
import path2 from "path";
|
|
149
235
|
function getSourceOptions(project, source) {
|
|
150
|
-
return {
|
|
236
|
+
return {
|
|
237
|
+
docsDir: path2.resolve(project.rootDir, source.docsDir),
|
|
238
|
+
...source.fallbackOnly ? { fallbackOnly: true } : {},
|
|
239
|
+
...source.fallbackDocsDir ? {
|
|
240
|
+
fallbackDocsDir: path2.resolve(
|
|
241
|
+
project.rootDir,
|
|
242
|
+
source.fallbackDocsDir
|
|
243
|
+
)
|
|
244
|
+
} : {}
|
|
245
|
+
};
|
|
151
246
|
}
|
|
152
247
|
function resolveDocsRoute(project, segments = []) {
|
|
153
248
|
const source = project.sources.find(
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/project/localization.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
function getLocalizedProject(project, locale) {
|
|
4
|
+
const selected = project.localization?.locales.find(
|
|
5
|
+
(entry) => entry.path === locale
|
|
6
|
+
);
|
|
7
|
+
if (!selected) throw new Error(`Unknown documentation language: ${locale}`);
|
|
8
|
+
return {
|
|
9
|
+
...project,
|
|
10
|
+
locale: selected,
|
|
11
|
+
config: { ...project.config, lang: selected.code },
|
|
12
|
+
sources: project.sources.map((source) => {
|
|
13
|
+
const primary = source.localization?.docs[project.localization.defaultLocale] ?? source.fallbackDocsDir ?? source.docsDir;
|
|
14
|
+
const translated = source.localization?.docs[selected.code] ?? (!source.localization && !source.version && selected.folder ? `locale/${selected.folder}/docs` : void 0);
|
|
15
|
+
const isPrimary = selected.code === project.localization.defaultLocale;
|
|
16
|
+
return {
|
|
17
|
+
...source,
|
|
18
|
+
docsDir: isPrimary ? primary : translated ?? primary,
|
|
19
|
+
fallbackDocsDir: isPrimary ? void 0 : primary,
|
|
20
|
+
fallbackOnly: !isPrimary && !translated,
|
|
21
|
+
basePath: `/${selected.path}/docs`
|
|
22
|
+
};
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function getContentSources(project) {
|
|
27
|
+
return project.localization && !project.locale ? project.localization.locales.flatMap(
|
|
28
|
+
(locale) => getLocalizedProject(project, locale.path).sources
|
|
29
|
+
) : project.sources;
|
|
30
|
+
}
|
|
31
|
+
function getDocsHref(project, source = project.sources[0], slug = "") {
|
|
32
|
+
const base = source.basePath ?? (project.localization ? `/${project.localization.locales.find((entry) => entry.code === project.localization.defaultLocale).path}/docs` : "/docs");
|
|
33
|
+
return [
|
|
34
|
+
base,
|
|
35
|
+
source.routePrefix,
|
|
36
|
+
...slug.split("/").filter(Boolean).map(encodeURIComponent)
|
|
37
|
+
].filter(Boolean).join("/");
|
|
38
|
+
}
|
|
39
|
+
function getLanguageLinks(project, source, slug = "") {
|
|
40
|
+
if (!project.localization) return [];
|
|
41
|
+
const visible = new Set(
|
|
42
|
+
(project.sources[0]?.localization?.locales ?? project.localization.locales).map((locale) => locale.code)
|
|
43
|
+
);
|
|
44
|
+
for (const locale of source.localization?.locales ?? [])
|
|
45
|
+
visible.add(locale.code);
|
|
46
|
+
if (project.locale) visible.add(project.locale.code);
|
|
47
|
+
return project.localization.locales.filter((locale) => visible.has(locale.code)).map((locale) => {
|
|
48
|
+
const view = getLocalizedProject(project, locale.path);
|
|
49
|
+
return {
|
|
50
|
+
code: locale.code,
|
|
51
|
+
label: source.localization?.locales.find(
|
|
52
|
+
(entry) => entry.code === locale.code
|
|
53
|
+
)?.label ?? locale.label,
|
|
54
|
+
href: getDocsHref(
|
|
55
|
+
view,
|
|
56
|
+
view.sources.find((entry) => entry.id === source.id),
|
|
57
|
+
slug
|
|
58
|
+
)
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function isFallbackPage(project, source, sourcePath) {
|
|
63
|
+
return !!source.fallbackDocsDir && !path.relative(
|
|
64
|
+
path.resolve(project.rootDir, source.fallbackDocsDir),
|
|
65
|
+
sourcePath
|
|
66
|
+
).startsWith("..");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
getLocalizedProject,
|
|
71
|
+
getContentSources,
|
|
72
|
+
getDocsHref,
|
|
73
|
+
getLanguageLinks,
|
|
74
|
+
isFallbackPage
|
|
75
|
+
};
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare class RdxConfigError extends Error {
|
|
4
|
-
constructor(message: string);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/** Resolve project-owned paths without allowing traversal or filesystem roots. */
|
|
8
|
-
declare function resolveProjectPath(rootDir: string, value: string, field: string): string;
|
|
9
|
-
declare function resolveConfig(input: unknown): ResolvedRdxConfig;
|
|
10
|
-
declare function defineConfig(config: RDXConfig): RDXConfig;
|
|
11
|
-
declare function createRdxProject(input: unknown, { rootDir, command, }?: {
|
|
12
|
-
rootDir?: string;
|
|
13
|
-
command?: string;
|
|
14
|
-
}): Promise<RdxProject>;
|
|
15
|
-
|
|
16
|
-
export { RdxConfigError, createRdxProject, defineConfig, resolveConfig, resolveProjectPath };
|
|
1
|
+
import '@lexibase/rdx-types';
|
|
2
|
+
export { R as RdxConfigError, h as collectSnapshotContributions, c as createRdxProject, d as defineConfig, g as getContentSources, n as normalizeLocalization, r as resolveConfig, f as resolveProjectPath } from '../index-DjuvW7o_.js';
|
package/dist/config/index.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RdxConfigError,
|
|
3
|
+
collectSnapshotContributions,
|
|
3
4
|
createRdxProject,
|
|
4
5
|
defineConfig,
|
|
6
|
+
normalizeLocalization,
|
|
5
7
|
resolveConfig,
|
|
6
8
|
resolveProjectPath
|
|
7
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-GYLAW7YX.js";
|
|
10
|
+
import {
|
|
11
|
+
getContentSources
|
|
12
|
+
} from "../chunk-SNNEXRLQ.js";
|
|
8
13
|
export {
|
|
9
14
|
RdxConfigError,
|
|
15
|
+
collectSnapshotContributions,
|
|
10
16
|
createRdxProject,
|
|
11
17
|
defineConfig,
|
|
18
|
+
getContentSources,
|
|
19
|
+
normalizeLocalization,
|
|
12
20
|
resolveConfig,
|
|
13
21
|
resolveProjectPath
|
|
14
22
|
};
|
|
@@ -2,6 +2,9 @@ interface DocumentLinkOptions {
|
|
|
2
2
|
sourceRoot: string;
|
|
3
3
|
sourcePath: string;
|
|
4
4
|
routePrefix?: string;
|
|
5
|
+
basePath?: string;
|
|
6
|
+
/** Resolve missing translated files against the effective primary inventory. */
|
|
7
|
+
virtualPaths?: boolean;
|
|
5
8
|
documents: readonly {
|
|
6
9
|
sourcePath: string;
|
|
7
10
|
slug: string;
|
|
@@ -11,7 +14,7 @@ declare class RdxDocumentLinkError extends Error {
|
|
|
11
14
|
readonly reason: string;
|
|
12
15
|
constructor(sourcePath: string, href: string, reason: string);
|
|
13
16
|
}
|
|
14
|
-
/** Resolve only explicit relative
|
|
17
|
+
/** Resolve only explicit relative Markdown links within the current content source. */
|
|
15
18
|
declare function createDocumentLinkResolver(options: DocumentLinkOptions): (href: string) => string;
|
|
16
19
|
/** A remark adapter shared by generated sites and the development website. */
|
|
17
20
|
declare function remarkDocumentLinks(options?: DocumentLinkOptions): ((tree: unknown) => void) | undefined;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RdxLocalization, RdxPluginContext, RdxProject, RdxContentSource, RDXConfig, ResolvedRdxConfig } from '@lexibase/rdx-types';
|
|
2
|
+
|
|
3
|
+
declare class RdxConfigError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** Resolve project-owned paths without allowing traversal or filesystem roots. */
|
|
8
|
+
declare function resolveProjectPath(rootDir: string, value: string, field: string): string;
|
|
9
|
+
|
|
10
|
+
/** Validate language identities without depending on live filesystem trees. */
|
|
11
|
+
declare function normalizeLocalization(input: unknown, language: string): RdxLocalization;
|
|
12
|
+
|
|
13
|
+
/** Gather and validate every participant before the first destination is reserved. */
|
|
14
|
+
declare function collectSnapshotContributions(context: RdxPluginContext, options: {
|
|
15
|
+
version: string;
|
|
16
|
+
snapshotDir: string;
|
|
17
|
+
sourceDir: string;
|
|
18
|
+
}): {
|
|
19
|
+
rootDir: string;
|
|
20
|
+
directories: {
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
}[];
|
|
24
|
+
files: {
|
|
25
|
+
filename: string;
|
|
26
|
+
content: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** Select a language without mutating the shared project or rerunning plugin hooks. */
|
|
31
|
+
declare function getLocalizedProject(project: RdxProject, locale: string): RdxProject;
|
|
32
|
+
declare function getContentSources(project: RdxProject): RdxContentSource[];
|
|
33
|
+
declare function getDocsHref(project: RdxProject, source?: RdxContentSource, slug?: string): string;
|
|
34
|
+
/** Navbar language links retain both the page and the selected edition. */
|
|
35
|
+
declare function getLanguageLinks(project: RdxProject, source: RdxContentSource, slug?: string): {
|
|
36
|
+
code: string;
|
|
37
|
+
label: string;
|
|
38
|
+
href: string;
|
|
39
|
+
}[];
|
|
40
|
+
declare function isFallbackPage(project: RdxProject, source: RdxContentSource, sourcePath: string): boolean;
|
|
41
|
+
|
|
42
|
+
declare function resolveConfig(input: unknown): ResolvedRdxConfig;
|
|
43
|
+
declare function defineConfig(config: RDXConfig): RDXConfig;
|
|
44
|
+
declare function createRdxProject(input: unknown, { rootDir, command, }?: {
|
|
45
|
+
rootDir?: string;
|
|
46
|
+
command?: string;
|
|
47
|
+
}): Promise<RdxProject>;
|
|
48
|
+
|
|
49
|
+
export { RdxConfigError as R, getDocsHref as a, getLanguageLinks as b, createRdxProject as c, defineConfig as d, getLocalizedProject as e, resolveProjectPath as f, getContentSources as g, collectSnapshotContributions as h, isFallbackPage as i, normalizeLocalization as n, resolveConfig as r };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _lexibase_rdx_types from '@lexibase/rdx-types';
|
|
2
2
|
import { RdxDocsOptions, RdxDocCategory, RdxDocument, RdxProject, RdxContentSource } from '@lexibase/rdx-types';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { R as RdxConfigError, c as createRdxProject, d as defineConfig, g as getContentSources, a as getDocsHref, b as getLanguageLinks, e as getLocalizedProject, i as isFallbackPage, r as resolveConfig, f as resolveProjectPath } from './index-DjuvW7o_.js';
|
|
4
|
+
export { D as DocumentLinkOptions, R as RdxDocumentLinkError, c as createDocumentLinkResolver } from './document-links-B9zsPsqx.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Reads the documentation tree from the user's project. The URL slug always
|
|
@@ -10,11 +10,13 @@ export { RdxConfigError, createRdxProject, defineConfig, resolveConfig, resolveP
|
|
|
10
10
|
* With onError, static readers collect per-file failures and retain fallback
|
|
11
11
|
* route metadata. Default callers keep the existing fail-fast behavior.
|
|
12
12
|
*/
|
|
13
|
-
declare function getDocsIndex({ docsDir }?: RdxDocsOptions, onError?: (error: unknown, sourcePath: string) => void): RdxDocCategory[];
|
|
13
|
+
declare function getDocsIndex({ docsDir, fallbackDocsDir, fallbackOnly }?: RdxDocsOptions, onError?: (error: unknown, sourcePath: string) => void): RdxDocCategory[];
|
|
14
14
|
declare function getDocsPaths(options?: RdxDocsOptions): string[];
|
|
15
|
-
declare function getDocument(slug: string, { docsDir }?: RdxDocsOptions): RdxDocument | null;
|
|
15
|
+
declare function getDocument(slug: string, { docsDir, fallbackDocsDir, fallbackOnly }?: RdxDocsOptions): RdxDocument | null;
|
|
16
16
|
|
|
17
17
|
declare function getSourceOptions(project: RdxProject, source: RdxContentSource): {
|
|
18
|
+
fallbackDocsDir?: string | undefined;
|
|
19
|
+
fallbackOnly?: boolean | undefined;
|
|
18
20
|
docsDir: string;
|
|
19
21
|
};
|
|
20
22
|
/** Match plugin routes before looking up pages in the live documentation. */
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RdxConfigError,
|
|
3
|
+
createRdxProject,
|
|
4
|
+
defineConfig,
|
|
5
|
+
resolveConfig,
|
|
6
|
+
resolveProjectPath
|
|
7
|
+
} from "./chunk-GYLAW7YX.js";
|
|
1
8
|
import {
|
|
2
9
|
getDocsIndex,
|
|
3
10
|
getDocsPaths,
|
|
@@ -5,29 +12,34 @@ import {
|
|
|
5
12
|
getProjectDocsPaths,
|
|
6
13
|
getSourceOptions,
|
|
7
14
|
resolveDocsRoute
|
|
8
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-M32EH5KP.js";
|
|
9
16
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
getContentSources,
|
|
18
|
+
getDocsHref,
|
|
19
|
+
getLanguageLinks,
|
|
20
|
+
getLocalizedProject,
|
|
21
|
+
isFallbackPage
|
|
22
|
+
} from "./chunk-SNNEXRLQ.js";
|
|
16
23
|
import {
|
|
17
24
|
RdxDocumentLinkError,
|
|
18
25
|
createDocumentLinkResolver
|
|
19
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-36CTLWNI.js";
|
|
20
27
|
export {
|
|
21
28
|
RdxConfigError,
|
|
22
29
|
RdxDocumentLinkError,
|
|
23
30
|
createDocumentLinkResolver,
|
|
24
31
|
createRdxProject,
|
|
25
32
|
defineConfig,
|
|
33
|
+
getContentSources,
|
|
34
|
+
getDocsHref,
|
|
26
35
|
getDocsIndex,
|
|
27
36
|
getDocsPaths,
|
|
28
37
|
getDocument,
|
|
38
|
+
getLanguageLinks,
|
|
39
|
+
getLocalizedProject,
|
|
29
40
|
getProjectDocsPaths,
|
|
30
41
|
getSourceOptions,
|
|
42
|
+
isFallbackPage,
|
|
31
43
|
resolveConfig,
|
|
32
44
|
resolveDocsRoute,
|
|
33
45
|
resolveProjectPath
|
package/dist/mdx/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DocumentLinkOptions, r as remarkDocumentLinks } from '../document-links-
|
|
1
|
+
export { D as DocumentLinkOptions, r as remarkDocumentLinks } from '../document-links-B9zsPsqx.js';
|
|
2
2
|
export { default as rehypeDocumentationHeadings } from 'rehype-slug';
|
|
3
3
|
import rehypeShiki from '@shikijs/rehype';
|
|
4
4
|
import remarkDirective from 'remark-directive';
|
package/dist/mdx/index.js
CHANGED
package/dist/search/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ interface SearchDocument {
|
|
|
6
6
|
category: string;
|
|
7
7
|
href: string;
|
|
8
8
|
content: string;
|
|
9
|
+
/** Original filename selects Markdown or MDX parsing. Omitted defaults to MDX. */
|
|
10
|
+
sourcePath?: string;
|
|
9
11
|
}
|
|
10
12
|
/** Parse text/sections without compiling MDX, evaluating JS, or exposing paths. */
|
|
11
13
|
declare function buildSearchIndex(documents: SearchDocument[]): RdxSearchIndex;
|
package/dist/search/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import remarkMdx from "remark-mdx";
|
|
|
12
12
|
import remarkParse from "remark-parse";
|
|
13
13
|
import { unified } from "unified";
|
|
14
14
|
var parser = unified().use(remarkParse).use(remarkGfm).use(remarkMdx).use(remarkDocumentationComponents);
|
|
15
|
+
var markdownParser = unified().use(remarkParse).use(remarkGfm).use(remarkDocumentationComponents);
|
|
15
16
|
function text(node) {
|
|
16
17
|
if (node.type === "break") return " ";
|
|
17
18
|
if (["mdxjsEsm", "mdxFlowExpression", "mdxTextExpression", "html"].includes(
|
|
@@ -82,7 +83,8 @@ function buildSearchIndex(documents) {
|
|
|
82
83
|
var visit = visit2;
|
|
83
84
|
const firstEntry = entries.length;
|
|
84
85
|
const slugger = new GithubSlugger();
|
|
85
|
-
const
|
|
86
|
+
const processor = document.sourcePath?.endsWith(".md") ? markdownParser : parser;
|
|
87
|
+
const tree = processor.runSync(processor.parse(document.content), {
|
|
86
88
|
value: document.content
|
|
87
89
|
});
|
|
88
90
|
let current = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexibase/rdx-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Content indexing and document utilities for RDX documentation projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
"remark-mdx": "^3.1.1",
|
|
55
55
|
"remark-parse": "^11.0.0",
|
|
56
56
|
"unified": "^11.0.5",
|
|
57
|
-
"@lexibase/rdx-types": "2.
|
|
57
|
+
"@lexibase/rdx-types": "2.2.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^22.15.3",
|
|
61
61
|
"@types/react": "19.3.0",
|
|
62
|
-
"@rdx/
|
|
63
|
-
"@rdx/
|
|
62
|
+
"@rdx/typescript-config": "1.0.0",
|
|
63
|
+
"@rdx/eslint-config": "1.0.0"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": "^22.18.0 || ^24.11.0"
|