@lexibase/rdx-core 3.1.1 → 3.3.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 +2 -2
- package/dist/{chunk-GBW4LSBN.js → chunk-5RUC6AZX.js} +1 -1
- package/dist/{chunk-KPVVN2MN.js → chunk-CRQU7OO4.js} +19 -1
- package/dist/{chunk-L7FZDK6G.js → chunk-GR2GL7HT.js} +17 -5
- package/dist/config/index.js +1 -1
- package/dist/{document-links-fo6ul9xz.d.ts → document-links-BQXyBubK.d.ts} +2 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +11 -4
- package/dist/mdx/index.d.ts +2 -2
- package/dist/mdx/index.js +1 -1
- package/package.json +4 -4
package/dist/check/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getDocsIndex,
|
|
3
3
|
getSourceOptions,
|
|
4
4
|
parseStaticDocument
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-5RUC6AZX.js";
|
|
6
6
|
import {
|
|
7
7
|
getContentSources,
|
|
8
8
|
isFallbackPage
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
RdxDocumentLinkError,
|
|
12
12
|
createDocumentLinkResolver
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-GR2GL7HT.js";
|
|
14
14
|
import {
|
|
15
15
|
headingText
|
|
16
16
|
} from "../chunk-FPBRKD4M.js";
|
|
@@ -709,6 +709,7 @@ function resolveConfig(input) {
|
|
|
709
709
|
config,
|
|
710
710
|
[
|
|
711
711
|
"description",
|
|
712
|
+
"basePath",
|
|
712
713
|
"metadata",
|
|
713
714
|
"lang",
|
|
714
715
|
"theme",
|
|
@@ -722,6 +723,10 @@ function resolveConfig(input) {
|
|
|
722
723
|
],
|
|
723
724
|
""
|
|
724
725
|
);
|
|
726
|
+
if (config.basePath !== void 0 && (typeof config.basePath !== "string" || !/^(?:\/[A-Za-z0-9._~-]+)+$/.test(config.basePath) || config.basePath.split("/").some((segment) => segment === "." || segment === "..")))
|
|
727
|
+
throw new RdxConfigError(
|
|
728
|
+
"basePath must start with / and contain URL-safe path segments without a trailing slash."
|
|
729
|
+
);
|
|
725
730
|
if (config.search !== void 0 && typeof config.search !== "boolean")
|
|
726
731
|
throw new RdxConfigError("search must be a boolean.");
|
|
727
732
|
if (config.TOC !== void 0 && typeof config.TOC !== "boolean")
|
|
@@ -782,11 +787,24 @@ function resolveConfig(input) {
|
|
|
782
787
|
const homepage = object(config.homepage, "homepage");
|
|
783
788
|
keys(
|
|
784
789
|
homepage,
|
|
785
|
-
[
|
|
790
|
+
[
|
|
791
|
+
"enabled",
|
|
792
|
+
"component",
|
|
793
|
+
"translations",
|
|
794
|
+
"title",
|
|
795
|
+
"description",
|
|
796
|
+
"buttons"
|
|
797
|
+
],
|
|
786
798
|
"homepage."
|
|
787
799
|
);
|
|
788
800
|
if (homepage.component !== void 0)
|
|
789
801
|
component(homepage.component, "homepage.component");
|
|
802
|
+
if (homepage.translations !== void 0 && typeof homepage.translations !== "boolean")
|
|
803
|
+
throw new RdxConfigError("homepage.translations must be a boolean.");
|
|
804
|
+
if (homepage.translations && homepage.component !== void 0)
|
|
805
|
+
throw new RdxConfigError(
|
|
806
|
+
"homepage.translations loads components/home.tsx. Use either homepage.translations or homepage.component."
|
|
807
|
+
);
|
|
790
808
|
if (homepage.enabled !== void 0 && typeof homepage.enabled !== "boolean")
|
|
791
809
|
throw new RdxConfigError("homepage.enabled must be a boolean.");
|
|
792
810
|
if (homepage.title !== void 0) text(homepage.title, "homepage.title");
|
|
@@ -93,6 +93,7 @@ function record(value) {
|
|
|
93
93
|
function remarkDocumentLinks(options) {
|
|
94
94
|
if (!options) return;
|
|
95
95
|
const resolve = createDocumentLinkResolver(options);
|
|
96
|
+
const publicHref = options.publicHref ?? ((href) => href);
|
|
96
97
|
return (tree) => {
|
|
97
98
|
const definitions = /* @__PURE__ */ new Map();
|
|
98
99
|
const identifier = (value) => value.trim().replace(/\s+/g, " ").toLowerCase();
|
|
@@ -110,25 +111,36 @@ function remarkDocumentLinks(options) {
|
|
|
110
111
|
});
|
|
111
112
|
visit(tree, (node) => {
|
|
112
113
|
if (node.type === "link" && typeof node.url === "string")
|
|
113
|
-
node.url = resolve(node.url);
|
|
114
|
+
node.url = publicHref(resolve(node.url));
|
|
114
115
|
if (node.type === "linkReference" && typeof node.identifier === "string") {
|
|
115
116
|
const definition = definitions.get(identifier(node.identifier));
|
|
116
117
|
if (typeof definition?.url === "string") {
|
|
117
118
|
node.type = "link";
|
|
118
|
-
node.url = resolve(definition.url);
|
|
119
|
+
node.url = publicHref(resolve(definition.url));
|
|
119
120
|
node.title = definition.title ?? null;
|
|
120
121
|
delete node.identifier;
|
|
121
122
|
delete node.referenceType;
|
|
122
123
|
delete node.label;
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
if ((node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") &&
|
|
126
|
+
if ((node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && Array.isArray(node.attributes)) {
|
|
126
127
|
for (const attribute of node.attributes) {
|
|
127
|
-
if (record(attribute) && attribute.type === "mdxJsxAttribute" &&
|
|
128
|
-
|
|
128
|
+
if (record(attribute) && attribute.type === "mdxJsxAttribute" && typeof attribute.value === "string") {
|
|
129
|
+
if (node.name === "a" && attribute.name === "href")
|
|
130
|
+
attribute.value = publicHref(resolve(attribute.value));
|
|
131
|
+
else if (attribute.name === "src" && ["img", "video", "audio", "source", "track", "iframe"].includes(
|
|
132
|
+
String(node.name)
|
|
133
|
+
) || attribute.name === "poster" && node.name === "video")
|
|
134
|
+
attribute.value = publicHref(attribute.value);
|
|
135
|
+
}
|
|
129
136
|
}
|
|
130
137
|
}
|
|
131
138
|
});
|
|
139
|
+
if (options.publicHref)
|
|
140
|
+
visit(tree, (node) => {
|
|
141
|
+
if ((node.type === "image" || node.type === "definition") && typeof node.url === "string")
|
|
142
|
+
node.url = publicHref(node.url);
|
|
143
|
+
});
|
|
132
144
|
};
|
|
133
145
|
}
|
|
134
146
|
|
package/dist/config/index.js
CHANGED
|
@@ -10,6 +10,8 @@ interface DocumentLinkOptions {
|
|
|
10
10
|
slug: string;
|
|
11
11
|
}[];
|
|
12
12
|
documentHref?: (slug: string) => string;
|
|
13
|
+
/** Map resolved links and root-relative assets to their public URLs. */
|
|
14
|
+
publicHref?: (href: string) => string;
|
|
13
15
|
}
|
|
14
16
|
declare class RdxDocumentLinkError extends Error {
|
|
15
17
|
readonly reason: string;
|
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
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-CIBgPARs.js';
|
|
4
|
-
export { D as DocumentLinkOptions, R as RdxDocumentLinkError, c as createDocumentLinkResolver } from './document-links-
|
|
4
|
+
export { D as DocumentLinkOptions, R as RdxDocumentLinkError, c as createDocumentLinkResolver } from './document-links-BQXyBubK.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Reads the documentation tree from the user's project. The URL slug always
|
|
@@ -14,6 +14,9 @@ declare function getDocsIndex({ docsDir, fallbackDocsDir, fallbackOnly }?: RdxDo
|
|
|
14
14
|
declare function getDocsPaths(options?: RdxDocsOptions): string[];
|
|
15
15
|
declare function getDocument(slug: string, { docsDir, fallbackDocsDir, fallbackOnly }?: RdxDocsOptions): RdxDocument | null;
|
|
16
16
|
|
|
17
|
+
/** Convert an app-relative URL for consumers that do not use the Next router. */
|
|
18
|
+
declare function withBasePath(href: string, basePath?: string): string;
|
|
19
|
+
|
|
17
20
|
declare function getSourceOptions(project: RdxProject, source: RdxContentSource): {
|
|
18
21
|
fallbackDocsDir?: string | undefined;
|
|
19
22
|
fallbackOnly?: boolean | undefined;
|
|
@@ -28,4 +31,4 @@ declare function resolveDocsRoute(project: RdxProject, segments?: string[]): {
|
|
|
28
31
|
};
|
|
29
32
|
declare function getProjectDocsPaths(project: RdxProject): string[];
|
|
30
33
|
|
|
31
|
-
export { getDocsIndex, getDocsPaths, getDocument, getProjectDocsPaths, getSourceOptions, resolveDocsRoute };
|
|
34
|
+
export { getDocsIndex, getDocsPaths, getDocument, getProjectDocsPaths, getSourceOptions, resolveDocsRoute, withBasePath };
|
package/dist/index.js
CHANGED
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
getProjectDocsPaths,
|
|
6
6
|
getSourceOptions,
|
|
7
7
|
resolveDocsRoute
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5RUC6AZX.js";
|
|
9
9
|
import {
|
|
10
10
|
RdxConfigError,
|
|
11
11
|
createRdxProject,
|
|
12
12
|
defineConfig,
|
|
13
13
|
resolveConfig,
|
|
14
14
|
resolveProjectPath
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CRQU7OO4.js";
|
|
16
16
|
import {
|
|
17
17
|
getContentSources,
|
|
18
18
|
getDocsHref,
|
|
@@ -23,7 +23,13 @@ import {
|
|
|
23
23
|
import {
|
|
24
24
|
RdxDocumentLinkError,
|
|
25
25
|
createDocumentLinkResolver
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-GR2GL7HT.js";
|
|
27
|
+
|
|
28
|
+
// src/content/base-path.ts
|
|
29
|
+
function withBasePath(href, basePath) {
|
|
30
|
+
if (!basePath || !href.startsWith("/") || href.startsWith("//")) return href;
|
|
31
|
+
return basePath + (href === "/" || /^\/[?#]/.test(href) ? href.slice(1) : href);
|
|
32
|
+
}
|
|
27
33
|
export {
|
|
28
34
|
RdxConfigError,
|
|
29
35
|
RdxDocumentLinkError,
|
|
@@ -42,5 +48,6 @@ export {
|
|
|
42
48
|
isFallbackPage,
|
|
43
49
|
resolveConfig,
|
|
44
50
|
resolveDocsRoute,
|
|
45
|
-
resolveProjectPath
|
|
51
|
+
resolveProjectPath,
|
|
52
|
+
withBasePath
|
|
46
53
|
};
|
package/dist/mdx/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DocumentLinkOptions } from '../document-links-
|
|
2
|
-
export { r as remarkDocumentLinks } from '../document-links-
|
|
1
|
+
import { D as DocumentLinkOptions } from '../document-links-BQXyBubK.js';
|
|
2
|
+
export { r as remarkDocumentLinks } from '../document-links-BQXyBubK.js';
|
|
3
3
|
export { default as rehypeDocumentationHeadings } from 'rehype-slug';
|
|
4
4
|
import rehypeShiki from '@shikijs/rehype';
|
|
5
5
|
import { RdxProject, RDXConfig } from '@lexibase/rdx-types';
|
package/dist/mdx/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexibase/rdx-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Content indexing and document utilities for RDX documentation projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"remark-stringify": "^11.0.0",
|
|
57
57
|
"shiki": "^4.5.0",
|
|
58
58
|
"unified": "^11.0.5",
|
|
59
|
-
"@lexibase/rdx-types": "2.
|
|
59
|
+
"@lexibase/rdx-types": "2.7.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/node": "^22.15.3",
|
|
63
63
|
"@types/react": "19.3.0",
|
|
64
|
-
"@rdx/
|
|
65
|
-
"@rdx/
|
|
64
|
+
"@rdx/eslint-config": "1.0.0",
|
|
65
|
+
"@rdx/typescript-config": "1.0.0"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": "^22.18.0 || ^24.11.0"
|