@lexibase/rdx-core 2.2.0 → 3.0.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/dist/check/index.js +3 -3
- package/dist/{chunk-J7VCQHSL.js → chunk-6WNFE2QG.js} +15 -1
- package/dist/{chunk-GYLAW7YX.js → chunk-FZGWKA74.js} +117 -4
- package/dist/{chunk-M32EH5KP.js → chunk-GBW4LSBN.js} +59 -36
- package/dist/{chunk-36CTLWNI.js → chunk-L7FZDK6G.js} +34 -11
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +13 -3
- package/dist/{document-links-B9zsPsqx.d.ts → document-links-fo6ul9xz.d.ts} +1 -0
- package/dist/{index-DjuvW7o_.d.ts → index-CIBgPARs.d.ts} +8 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -9
- package/dist/mdx/index.d.ts +6 -2
- package/dist/mdx/index.js +31 -2
- package/dist/search/index.js +2 -2
- package/package.json +5 -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-GBW4LSBN.js";
|
|
6
6
|
import {
|
|
7
7
|
getContentSources,
|
|
8
8
|
isFallbackPage
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
RdxDocumentLinkError,
|
|
12
12
|
createDocumentLinkResolver
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-L7FZDK6G.js";
|
|
14
14
|
import {
|
|
15
15
|
headingText
|
|
16
16
|
} from "../chunk-FPBRKD4M.js";
|
|
17
17
|
import {
|
|
18
18
|
remarkDocumentationComponents
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-6WNFE2QG.js";
|
|
20
20
|
|
|
21
21
|
// src/check/index.ts
|
|
22
22
|
import fs from "fs";
|
|
@@ -134,6 +134,18 @@ function container(node, source) {
|
|
|
134
134
|
)
|
|
135
135
|
]);
|
|
136
136
|
}
|
|
137
|
+
if (node.name === "steps") {
|
|
138
|
+
return component(
|
|
139
|
+
"Steps",
|
|
140
|
+
{},
|
|
141
|
+
groups.map(
|
|
142
|
+
(group) => component("Step", {}, [
|
|
143
|
+
component("StepTitle", {}, [{ type: "text", value: group.title }]),
|
|
144
|
+
...group.children
|
|
145
|
+
])
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
137
149
|
return component(
|
|
138
150
|
"Accordion",
|
|
139
151
|
{},
|
|
@@ -157,7 +169,9 @@ function remarkDocumentationComponents() {
|
|
|
157
169
|
if (["containerDirective", "leafDirective", "textDirective"].includes(
|
|
158
170
|
node.type
|
|
159
171
|
)) {
|
|
160
|
-
const known = ["tabs", "accordion", "kbd"].includes(
|
|
172
|
+
const known = ["tabs", "accordion", "steps", "kbd"].includes(
|
|
173
|
+
node.name ?? ""
|
|
174
|
+
);
|
|
161
175
|
if (!known) {
|
|
162
176
|
const value = source.slice(
|
|
163
177
|
node.position?.start.offset,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/config/index.ts
|
|
2
|
-
import
|
|
2
|
+
import path7 from "path";
|
|
3
3
|
import { existsSync, readdirSync } from "fs";
|
|
4
4
|
|
|
5
5
|
// src/config/error.ts
|
|
@@ -565,6 +565,103 @@ function collectSnapshotContributions(context, options) {
|
|
|
565
565
|
};
|
|
566
566
|
}
|
|
567
567
|
|
|
568
|
+
// src/config/edit-page.ts
|
|
569
|
+
import path5 from "path";
|
|
570
|
+
function getEditPageHref(project, source, sourcePath) {
|
|
571
|
+
const editPage = project.config.editPage;
|
|
572
|
+
if (!editPage || source?.id !== "current") return;
|
|
573
|
+
const relative = path5.relative(project.rootDir, sourcePath);
|
|
574
|
+
const segments = relative.split(path5.sep);
|
|
575
|
+
if (!relative || path5.isAbsolute(relative) || segments[0] === "..") return;
|
|
576
|
+
const url = new URL(editPage.baseUrl);
|
|
577
|
+
url.pathname = `${url.pathname.replace(/\/+$/, "")}/${segments.map(encodeURIComponent).join("/")}`;
|
|
578
|
+
return url.href;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// src/config/document-dates.ts
|
|
582
|
+
import { execFileSync } from "child_process";
|
|
583
|
+
import fs5 from "fs";
|
|
584
|
+
import path6 from "path";
|
|
585
|
+
var snapshotDatesFilename = "_rdx-last-updated.json";
|
|
586
|
+
var datePattern = /^\d{4}-\d{2}-\d{2}$/;
|
|
587
|
+
function relativeFile(root, file) {
|
|
588
|
+
const relative = path6.relative(root, file);
|
|
589
|
+
if (!relative || path6.isAbsolute(relative) || relative.split(path6.sep)[0] === "..")
|
|
590
|
+
return;
|
|
591
|
+
return relative.split(path6.sep).join("/");
|
|
592
|
+
}
|
|
593
|
+
function createDocumentDateReader(root) {
|
|
594
|
+
const git = (...args) => execFileSync("git", ["--literal-pathspecs", ...args], {
|
|
595
|
+
cwd: root,
|
|
596
|
+
encoding: "utf8",
|
|
597
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
598
|
+
timeout: 3e3,
|
|
599
|
+
windowsHide: true
|
|
600
|
+
}).trim();
|
|
601
|
+
let shallow;
|
|
602
|
+
try {
|
|
603
|
+
shallow = git("rev-parse", "--is-shallow-repository") === "true";
|
|
604
|
+
} catch {
|
|
605
|
+
return () => void 0;
|
|
606
|
+
}
|
|
607
|
+
return (file) => {
|
|
608
|
+
const relative = relativeFile(root, file);
|
|
609
|
+
if (!relative) return;
|
|
610
|
+
try {
|
|
611
|
+
git("ls-files", "--error-unmatch", "--", relative);
|
|
612
|
+
git("diff", "--quiet", "--no-ext-diff", "HEAD", "--", relative);
|
|
613
|
+
const [date, parents] = git(
|
|
614
|
+
"log",
|
|
615
|
+
"-1",
|
|
616
|
+
"--format=%cs%x00%P",
|
|
617
|
+
"HEAD",
|
|
618
|
+
"--",
|
|
619
|
+
relative
|
|
620
|
+
).split("\0");
|
|
621
|
+
if (date && datePattern.test(date) && (!shallow || parents)) return date;
|
|
622
|
+
} catch {
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function collectSnapshotDocumentDates(directory, dateFor) {
|
|
627
|
+
const dates = /* @__PURE__ */ Object.create(null);
|
|
628
|
+
function visit(folder) {
|
|
629
|
+
for (const entry of fs5.readdirSync(
|
|
630
|
+
/* turbopackIgnore: true */
|
|
631
|
+
folder,
|
|
632
|
+
{ withFileTypes: true }
|
|
633
|
+
).sort((a, b) => a.name.localeCompare(b.name, "en"))) {
|
|
634
|
+
const file = path6.join(folder, entry.name);
|
|
635
|
+
if (entry.isDirectory()) visit(file);
|
|
636
|
+
else if (entry.isFile() && /\.mdx?$/.test(entry.name)) {
|
|
637
|
+
const date = dateFor(file);
|
|
638
|
+
if (date) dates[relativeFile(directory, file)] = date;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
visit(directory);
|
|
643
|
+
return Object.keys(dates).length ? JSON.stringify(dates, null, 2) + "\n" : void 0;
|
|
644
|
+
}
|
|
645
|
+
function getSnapshotDocumentDate(directory, file) {
|
|
646
|
+
const relative = relativeFile(directory, file);
|
|
647
|
+
if (!relative) return;
|
|
648
|
+
try {
|
|
649
|
+
const filename = path6.join(directory, snapshotDatesFilename);
|
|
650
|
+
const dates = JSON.parse(
|
|
651
|
+
fs5.readFileSync(
|
|
652
|
+
/* turbopackIgnore: true */
|
|
653
|
+
filename,
|
|
654
|
+
"utf8"
|
|
655
|
+
)
|
|
656
|
+
);
|
|
657
|
+
if (!dates || typeof dates !== "object" || !Object.hasOwn(dates, relative))
|
|
658
|
+
return;
|
|
659
|
+
const date = dates[relative];
|
|
660
|
+
if (typeof date === "string" && datePattern.test(date)) return date;
|
|
661
|
+
} catch {
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
568
665
|
// src/config/index.ts
|
|
569
666
|
function record(value) {
|
|
570
667
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -618,7 +715,8 @@ function resolveConfig(input) {
|
|
|
618
715
|
"plugins",
|
|
619
716
|
"homepage",
|
|
620
717
|
"TOC",
|
|
621
|
-
"search"
|
|
718
|
+
"search",
|
|
719
|
+
"editPage"
|
|
622
720
|
],
|
|
623
721
|
""
|
|
624
722
|
);
|
|
@@ -630,6 +728,16 @@ function resolveConfig(input) {
|
|
|
630
728
|
text(config.description, "description", true);
|
|
631
729
|
if (config.lang !== void 0) text(config.lang, "lang");
|
|
632
730
|
validateMetadata(config.metadata);
|
|
731
|
+
if (config.editPage !== void 0 && config.editPage !== false) {
|
|
732
|
+
const editPage = object(config.editPage, "editPage");
|
|
733
|
+
keys(editPage, ["baseUrl"], "editPage.");
|
|
734
|
+
const value = text(editPage.baseUrl, "editPage.baseUrl");
|
|
735
|
+
const url = URL.parse(value);
|
|
736
|
+
if (!/^https?:\/\//i.test(value) || /[\s\\?#]/.test(value) || !url || url.username || url.password)
|
|
737
|
+
throw new RdxConfigError(
|
|
738
|
+
"editPage.baseUrl must be an absolute HTTP(S) edit URL without credentials, a query, or a fragment."
|
|
739
|
+
);
|
|
740
|
+
}
|
|
633
741
|
if (config.homepage !== void 0) {
|
|
634
742
|
const homepage = object(config.homepage, "homepage");
|
|
635
743
|
keys(
|
|
@@ -754,7 +862,7 @@ async function createRdxProject(input, {
|
|
|
754
862
|
rootDir = process.cwd(),
|
|
755
863
|
command = "runtime"
|
|
756
864
|
} = {}) {
|
|
757
|
-
rootDir =
|
|
865
|
+
rootDir = path7.resolve(
|
|
758
866
|
/* turbopackIgnore: true */
|
|
759
867
|
rootDir
|
|
760
868
|
);
|
|
@@ -830,7 +938,7 @@ async function createRdxProject(input, {
|
|
|
830
938
|
const field = `plugin "${plugin.name}" runtimeFiles`;
|
|
831
939
|
const filename = text(value, field);
|
|
832
940
|
const resolved = resolveProjectPath(rootDir, filename, field);
|
|
833
|
-
runtimeFiles.add(
|
|
941
|
+
runtimeFiles.add(path7.relative(rootDir, resolved));
|
|
834
942
|
}
|
|
835
943
|
}
|
|
836
944
|
if (contribution.sources === void 0) continue;
|
|
@@ -941,6 +1049,11 @@ export {
|
|
|
941
1049
|
normalizeLocalization,
|
|
942
1050
|
resolveProjectPath,
|
|
943
1051
|
collectSnapshotContributions,
|
|
1052
|
+
getEditPageHref,
|
|
1053
|
+
snapshotDatesFilename,
|
|
1054
|
+
createDocumentDateReader,
|
|
1055
|
+
collectSnapshotDocumentDates,
|
|
1056
|
+
getSnapshotDocumentDate,
|
|
944
1057
|
resolveConfig,
|
|
945
1058
|
defineConfig,
|
|
946
1059
|
createRdxProject
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_POSITION,
|
|
3
|
+
documentExtension,
|
|
4
|
+
orderedName,
|
|
5
|
+
slugFromRelativePath
|
|
6
|
+
} from "./chunk-L7FZDK6G.js";
|
|
7
|
+
|
|
1
8
|
// src/content/static-source.ts
|
|
2
9
|
import matter from "gray-matter";
|
|
3
10
|
function parseStaticDocument(source) {
|
|
@@ -16,9 +23,6 @@ function parseStaticDocument(source) {
|
|
|
16
23
|
import fs from "fs";
|
|
17
24
|
import path from "path";
|
|
18
25
|
import matter2 from "gray-matter";
|
|
19
|
-
var DOCUMENT_EXTENSIONS = [".md", ".mdx"];
|
|
20
|
-
var documentExtension = /\.mdx?$/;
|
|
21
|
-
var DEFAULT_POSITION = Number.MAX_SAFE_INTEGER;
|
|
22
26
|
function getDocsRoot(docsDir = "docs") {
|
|
23
27
|
return path.resolve(
|
|
24
28
|
/* turbopackIgnore: true */
|
|
@@ -38,13 +42,13 @@ function stringValue(value, fallback) {
|
|
|
38
42
|
function numberValue(value, fallback = DEFAULT_POSITION) {
|
|
39
43
|
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
40
44
|
}
|
|
41
|
-
function readCategoryMeta(categoryPath, fallbackTitle) {
|
|
45
|
+
function readCategoryMeta(categoryPath, fallbackTitle, position = DEFAULT_POSITION) {
|
|
42
46
|
const metaPath = path.join(categoryPath, "_category.json");
|
|
43
47
|
if (!fs.existsSync(
|
|
44
48
|
/* turbopackIgnore: true */
|
|
45
49
|
metaPath
|
|
46
50
|
)) {
|
|
47
|
-
return { title: fallbackTitle, position
|
|
51
|
+
return { title: fallbackTitle, position };
|
|
48
52
|
}
|
|
49
53
|
try {
|
|
50
54
|
const parsed = JSON.parse(
|
|
@@ -55,14 +59,14 @@ function readCategoryMeta(categoryPath, fallbackTitle) {
|
|
|
55
59
|
)
|
|
56
60
|
);
|
|
57
61
|
if (!isRecord(parsed)) {
|
|
58
|
-
return { title: fallbackTitle, position
|
|
62
|
+
return { title: fallbackTitle, position };
|
|
59
63
|
}
|
|
60
64
|
return {
|
|
61
65
|
title: stringValue(parsed.title, fallbackTitle),
|
|
62
|
-
position: numberValue(parsed.sidebar_position)
|
|
66
|
+
position: numberValue(parsed.sidebar_position, position)
|
|
63
67
|
};
|
|
64
68
|
} catch {
|
|
65
|
-
return { title: fallbackTitle, position
|
|
69
|
+
return { title: fallbackTitle, position };
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
function findDocumentFiles(directory) {
|
|
@@ -78,8 +82,21 @@ function findDocumentFiles(directory) {
|
|
|
78
82
|
return [];
|
|
79
83
|
});
|
|
80
84
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
85
|
+
function matchingEntries(directory, name, folders) {
|
|
86
|
+
if (!fs.existsSync(
|
|
87
|
+
/* turbopackIgnore: true */
|
|
88
|
+
directory
|
|
89
|
+
)) return [];
|
|
90
|
+
return fs.readdirSync(
|
|
91
|
+
/* turbopackIgnore: true */
|
|
92
|
+
directory,
|
|
93
|
+
{ withFileTypes: true }
|
|
94
|
+
).flatMap((entry) => {
|
|
95
|
+
if (folders ? !entry.isDirectory() : !entry.isFile() || !documentExtension.test(entry.name))
|
|
96
|
+
return [];
|
|
97
|
+
const candidate = folders ? entry.name : entry.name.replace(documentExtension, "");
|
|
98
|
+
return orderedName(candidate).name === name ? [path.join(directory, entry.name)] : [];
|
|
99
|
+
});
|
|
83
100
|
}
|
|
84
101
|
function isSafeSlug(slug) {
|
|
85
102
|
if (path.isAbsolute(slug) || slug.includes("\\")) return false;
|
|
@@ -96,13 +113,11 @@ function getDocsIndex({ docsDir, fallbackDocsDir, fallbackOnly } = {}, onError)
|
|
|
96
113
|
(category) => category.pages.map((page) => [page.slug, page])
|
|
97
114
|
)
|
|
98
115
|
);
|
|
116
|
+
const translatedRoot = getDocsRoot(docsDir);
|
|
99
117
|
return primary.map((category) => ({
|
|
100
118
|
...category,
|
|
101
119
|
title: readCategoryMeta(
|
|
102
|
-
path.join(
|
|
103
|
-
getDocsRoot(docsDir),
|
|
104
|
-
category.id === "_root" ? "" : category.id
|
|
105
|
-
),
|
|
120
|
+
category.id === "_root" ? translatedRoot : matchingEntries(translatedRoot, category.id, true)[0] ?? path.join(translatedRoot, category.id),
|
|
106
121
|
category.title
|
|
107
122
|
).title,
|
|
108
123
|
pages: category.pages.map((page) => ({
|
|
@@ -132,12 +147,17 @@ function getDocsIndex({ docsDir, fallbackDocsDir, fallbackOnly } = {}, onError)
|
|
|
132
147
|
slugs.set(slug, filePath);
|
|
133
148
|
const relativePath = path.relative(docsRoot, filePath);
|
|
134
149
|
const pathParts = relativePath.split(path.sep);
|
|
135
|
-
const
|
|
136
|
-
const
|
|
150
|
+
const categoryFolder = pathParts.length > 1 ? pathParts[0] ?? "_root" : "_root";
|
|
151
|
+
const { name: categoryId, position: categoryPosition } = orderedName(categoryFolder);
|
|
152
|
+
const categoryPath = categoryFolder === "_root" ? docsRoot : path.join(docsRoot, categoryFolder);
|
|
137
153
|
const fallbackCategoryTitle = categoryId === "_root" ? "Overview" : toTitle(categoryId);
|
|
138
154
|
let category = categories.get(categoryId);
|
|
139
155
|
if (!category) {
|
|
140
|
-
const meta = readCategoryMeta(
|
|
156
|
+
const meta = readCategoryMeta(
|
|
157
|
+
categoryPath,
|
|
158
|
+
fallbackCategoryTitle,
|
|
159
|
+
categoryPosition
|
|
160
|
+
);
|
|
141
161
|
const createdCategory = {
|
|
142
162
|
id: categoryId,
|
|
143
163
|
title: meta.title,
|
|
@@ -162,11 +182,21 @@ function getDocsIndex({ docsDir, fallbackDocsDir, fallbackOnly } = {}, onError)
|
|
|
162
182
|
onError(error, filePath);
|
|
163
183
|
}
|
|
164
184
|
const fallbackTitle = toTitle(path.basename(slug));
|
|
185
|
+
const navTitle = stringValue(frontmatter.navTitle, "");
|
|
186
|
+
const { highlighting } = frontmatter;
|
|
187
|
+
const filePosition = orderedName(
|
|
188
|
+
path.basename(relativePath).replace(documentExtension, "")
|
|
189
|
+
).position;
|
|
165
190
|
category.pages.push({
|
|
166
191
|
slug,
|
|
167
192
|
title: stringValue(frontmatter.title, fallbackTitle),
|
|
193
|
+
...navTitle ? { navTitle } : {},
|
|
194
|
+
...highlighting === "important" || highlighting === "new" ? { highlighting } : {},
|
|
168
195
|
description: stringValue(frontmatter.description, ""),
|
|
169
|
-
position: numberValue(
|
|
196
|
+
position: numberValue(
|
|
197
|
+
frontmatter.order,
|
|
198
|
+
numberValue(frontmatter.link_position, filePosition)
|
|
199
|
+
),
|
|
170
200
|
sourcePath: filePath
|
|
171
201
|
});
|
|
172
202
|
}
|
|
@@ -189,31 +219,24 @@ function getDocument(slug, { docsDir, fallbackDocsDir, fallbackOnly } = {}) {
|
|
|
189
219
|
if (fallbackOnly)
|
|
190
220
|
return getDocument(slug, { docsDir: fallbackDocsDir ?? docsDir });
|
|
191
221
|
const docsRoot = getDocsRoot(docsDir);
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
).isFile()
|
|
222
|
+
const parts = slug.split("/");
|
|
223
|
+
const name = parts.pop();
|
|
224
|
+
let directories = [docsRoot];
|
|
225
|
+
for (const part of parts)
|
|
226
|
+
directories = directories.flatMap(
|
|
227
|
+
(directory) => matchingEntries(directory, part, true)
|
|
228
|
+
);
|
|
229
|
+
const candidates = directories.flatMap(
|
|
230
|
+
(directory) => matchingEntries(directory, name, false)
|
|
202
231
|
);
|
|
203
232
|
if (candidates.length > 1)
|
|
204
233
|
throw new Error(
|
|
205
234
|
`[RDX] Duplicate documentation route "${slug}": ${candidates.join(" and ")}. Keep one page per route.`
|
|
206
235
|
);
|
|
207
|
-
const sourcePath = candidates[0] ?? path.resolve(docsRoot, `${slug}.mdx`);
|
|
208
|
-
const relativePath = path.relative(docsRoot, sourcePath);
|
|
209
|
-
if (relativePath.startsWith("..") || path.isAbsolute(relativePath))
|
|
210
|
-
return null;
|
|
211
236
|
if (fallbackDocsDir && !getDocument(slug, { docsDir: fallbackDocsDir }))
|
|
212
237
|
return null;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
sourcePath
|
|
216
|
-
))
|
|
238
|
+
const sourcePath = candidates[0];
|
|
239
|
+
if (!sourcePath)
|
|
217
240
|
return fallbackDocsDir ? getDocument(slug, { docsDir: fallbackDocsDir }) : null;
|
|
218
241
|
const parsed = matter2(
|
|
219
242
|
fs.readFileSync(
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
// src/content/document-links.ts
|
|
2
|
+
import path2 from "path";
|
|
3
|
+
|
|
4
|
+
// src/content/filenames.ts
|
|
2
5
|
import path from "path";
|
|
6
|
+
var documentExtension = /\.mdx?$/;
|
|
7
|
+
var DEFAULT_POSITION = Number.MAX_SAFE_INTEGER;
|
|
8
|
+
function orderedName(name) {
|
|
9
|
+
const match = /^(\d{2})-(.+)$/.exec(name);
|
|
10
|
+
return match && match[2] !== "." && match[2] !== ".." ? { name: match[2], position: Number(match[1]) } : { name, position: DEFAULT_POSITION };
|
|
11
|
+
}
|
|
12
|
+
function slugFromRelativePath(relativePath) {
|
|
13
|
+
return relativePath.replace(documentExtension, "").split(path.sep).map((segment) => orderedName(segment).name).join("/");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/content/document-links.ts
|
|
3
17
|
var RdxDocumentLinkError = class extends Error {
|
|
4
18
|
constructor(sourcePath, href, reason) {
|
|
5
19
|
super(`[RDX] Invalid document link "${href}" in ${sourcePath}: ${reason}`);
|
|
@@ -9,16 +23,16 @@ var RdxDocumentLinkError = class extends Error {
|
|
|
9
23
|
reason;
|
|
10
24
|
};
|
|
11
25
|
function createDocumentLinkResolver(options) {
|
|
12
|
-
const root =
|
|
13
|
-
const current =
|
|
26
|
+
const root = path2.resolve(options.sourceRoot);
|
|
27
|
+
const current = path2.resolve(options.sourcePath);
|
|
14
28
|
const documents = new Map(
|
|
15
29
|
options.documents.flatMap((page) => [
|
|
16
|
-
[
|
|
30
|
+
[path2.resolve(page.sourcePath), page.slug],
|
|
17
31
|
...options.virtualPaths ? [
|
|
18
32
|
[
|
|
19
|
-
|
|
33
|
+
path2.resolve(
|
|
20
34
|
root,
|
|
21
|
-
`${page.slug}${
|
|
35
|
+
`${page.slug}${path2.extname(page.sourcePath)}`
|
|
22
36
|
),
|
|
23
37
|
page.slug
|
|
24
38
|
]
|
|
@@ -49,18 +63,23 @@ function createDocumentLinkResolver(options) {
|
|
|
49
63
|
const fail = (reason) => {
|
|
50
64
|
throw new RdxDocumentLinkError(current, href, reason);
|
|
51
65
|
};
|
|
52
|
-
if (
|
|
66
|
+
if (path2.isAbsolute(decoded) || decoded.includes("\\") || decoded.includes("\0"))
|
|
53
67
|
fail("use forward-slash relative paths without null characters.");
|
|
54
|
-
const target =
|
|
55
|
-
const relative =
|
|
56
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
68
|
+
const target = path2.resolve(path2.dirname(current), decoded);
|
|
69
|
+
const relative = path2.relative(root, target);
|
|
70
|
+
if (relative === ".." || relative.startsWith(`..${path2.sep}`) || path2.isAbsolute(relative))
|
|
57
71
|
fail("the destination escapes this documentation source.");
|
|
58
|
-
const slug = documents.get(target) ??
|
|
72
|
+
const slug = documents.get(target) ?? (options.virtualPaths ? documents.get(
|
|
73
|
+
path2.resolve(
|
|
74
|
+
root,
|
|
75
|
+
`${slugFromRelativePath(relative)}${path2.extname(relative)}`
|
|
76
|
+
)
|
|
77
|
+
) : void 0) ?? fail(
|
|
59
78
|
`"${relative}" does not exist in this documentation source${options.routePrefix ? ` (${options.routePrefix})` : ""}.`
|
|
60
79
|
);
|
|
61
80
|
if ((routeCounts.get(slug) ?? 0) > 1)
|
|
62
81
|
fail("the destination has an ambiguous documentation route.");
|
|
63
|
-
const route = [
|
|
82
|
+
const route = options.documentHref?.(slug) ?? [
|
|
64
83
|
options.basePath ?? "/docs",
|
|
65
84
|
options.routePrefix && encodeURIComponent(options.routePrefix),
|
|
66
85
|
...slug.split("/").map(encodeURIComponent)
|
|
@@ -114,6 +133,10 @@ function remarkDocumentLinks(options) {
|
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
export {
|
|
136
|
+
documentExtension,
|
|
137
|
+
DEFAULT_POSITION,
|
|
138
|
+
orderedName,
|
|
139
|
+
slugFromRelativePath,
|
|
117
140
|
RdxDocumentLinkError,
|
|
118
141
|
createDocumentLinkResolver,
|
|
119
142
|
remarkDocumentLinks
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
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-
|
|
2
|
+
export { R as RdxConfigError, h as collectSnapshotContributions, j as collectSnapshotDocumentDates, k as createDocumentDateReader, c as createRdxProject, d as defineConfig, g as getContentSources, l as getEditPageHref, m as getSnapshotDocumentDate, n as normalizeLocalization, r as resolveConfig, f as resolveProjectPath, s as snapshotDatesFilename } from '../index-CIBgPARs.js';
|
package/dist/config/index.js
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RdxConfigError,
|
|
3
3
|
collectSnapshotContributions,
|
|
4
|
+
collectSnapshotDocumentDates,
|
|
5
|
+
createDocumentDateReader,
|
|
4
6
|
createRdxProject,
|
|
5
7
|
defineConfig,
|
|
8
|
+
getEditPageHref,
|
|
9
|
+
getSnapshotDocumentDate,
|
|
6
10
|
normalizeLocalization,
|
|
7
11
|
resolveConfig,
|
|
8
|
-
resolveProjectPath
|
|
9
|
-
|
|
12
|
+
resolveProjectPath,
|
|
13
|
+
snapshotDatesFilename
|
|
14
|
+
} from "../chunk-FZGWKA74.js";
|
|
10
15
|
import {
|
|
11
16
|
getContentSources
|
|
12
17
|
} from "../chunk-SNNEXRLQ.js";
|
|
13
18
|
export {
|
|
14
19
|
RdxConfigError,
|
|
15
20
|
collectSnapshotContributions,
|
|
21
|
+
collectSnapshotDocumentDates,
|
|
22
|
+
createDocumentDateReader,
|
|
16
23
|
createRdxProject,
|
|
17
24
|
defineConfig,
|
|
18
25
|
getContentSources,
|
|
26
|
+
getEditPageHref,
|
|
27
|
+
getSnapshotDocumentDate,
|
|
19
28
|
normalizeLocalization,
|
|
20
29
|
resolveConfig,
|
|
21
|
-
resolveProjectPath
|
|
30
|
+
resolveProjectPath,
|
|
31
|
+
snapshotDatesFilename
|
|
22
32
|
};
|
|
@@ -39,6 +39,13 @@ declare function getLanguageLinks(project: RdxProject, source: RdxContentSource,
|
|
|
39
39
|
}[];
|
|
40
40
|
declare function isFallbackPage(project: RdxProject, source: RdxContentSource, sourcePath: string): boolean;
|
|
41
41
|
|
|
42
|
+
declare function getEditPageHref(project: Pick<RdxProject, 'config' | 'rootDir'>, source: Pick<RdxContentSource, 'id'> | undefined, sourcePath: string): string | undefined;
|
|
43
|
+
|
|
44
|
+
declare const snapshotDatesFilename = "_rdx-last-updated.json";
|
|
45
|
+
declare function createDocumentDateReader(root: string): (file: string) => string | undefined;
|
|
46
|
+
declare function collectSnapshotDocumentDates(directory: string, dateFor: (file: string) => string | undefined): string | undefined;
|
|
47
|
+
declare function getSnapshotDocumentDate(directory: string, file: string): string | undefined;
|
|
48
|
+
|
|
42
49
|
declare function resolveConfig(input: unknown): ResolvedRdxConfig;
|
|
43
50
|
declare function defineConfig(config: RDXConfig): RDXConfig;
|
|
44
51
|
declare function createRdxProject(input: unknown, { rootDir, command, }?: {
|
|
@@ -46,4 +53,4 @@ declare function createRdxProject(input: unknown, { rootDir, command, }?: {
|
|
|
46
53
|
command?: string;
|
|
47
54
|
}): Promise<RdxProject>;
|
|
48
55
|
|
|
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 };
|
|
56
|
+
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, collectSnapshotDocumentDates as j, createDocumentDateReader as k, getEditPageHref as l, getSnapshotDocumentDate as m, normalizeLocalization as n, resolveConfig as r, snapshotDatesFilename as s };
|
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 { 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-
|
|
4
|
-
export { D as DocumentLinkOptions, R as RdxDocumentLinkError, c as createDocumentLinkResolver } from './document-links-
|
|
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-fo6ul9xz.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Reads the documentation tree from the user's project. The URL slug always
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RdxConfigError,
|
|
3
|
-
createRdxProject,
|
|
4
|
-
defineConfig,
|
|
5
|
-
resolveConfig,
|
|
6
|
-
resolveProjectPath
|
|
7
|
-
} from "./chunk-GYLAW7YX.js";
|
|
8
1
|
import {
|
|
9
2
|
getDocsIndex,
|
|
10
3
|
getDocsPaths,
|
|
@@ -12,7 +5,14 @@ import {
|
|
|
12
5
|
getProjectDocsPaths,
|
|
13
6
|
getSourceOptions,
|
|
14
7
|
resolveDocsRoute
|
|
15
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GBW4LSBN.js";
|
|
9
|
+
import {
|
|
10
|
+
RdxConfigError,
|
|
11
|
+
createRdxProject,
|
|
12
|
+
defineConfig,
|
|
13
|
+
resolveConfig,
|
|
14
|
+
resolveProjectPath
|
|
15
|
+
} from "./chunk-FZGWKA74.js";
|
|
16
16
|
import {
|
|
17
17
|
getContentSources,
|
|
18
18
|
getDocsHref,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import {
|
|
24
24
|
RdxDocumentLinkError,
|
|
25
25
|
createDocumentLinkResolver
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-L7FZDK6G.js";
|
|
27
27
|
export {
|
|
28
28
|
RdxConfigError,
|
|
29
29
|
RdxDocumentLinkError,
|
package/dist/mdx/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { D as DocumentLinkOptions } from '../document-links-fo6ul9xz.js';
|
|
2
|
+
export { r as remarkDocumentLinks } from '../document-links-fo6ul9xz.js';
|
|
2
3
|
export { default as rehypeDocumentationHeadings } from 'rehype-slug';
|
|
3
4
|
import rehypeShiki from '@shikijs/rehype';
|
|
4
5
|
import remarkDirective from 'remark-directive';
|
|
@@ -11,4 +12,7 @@ declare function remarkDocumentationComponents(this: ThisParameterType<typeof re
|
|
|
11
12
|
value: unknown;
|
|
12
13
|
}) => void;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
/** Serialize document content without evaluating or publishing MDX JavaScript. */
|
|
16
|
+
declare function exportMarkdownBody(content: string, links: DocumentLinkOptions): string;
|
|
17
|
+
|
|
18
|
+
export { DocumentLinkOptions, exportMarkdownBody, rehypeDocumentationCode, remarkDocumentationComponents };
|
package/dist/mdx/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
remarkDocumentLinks
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-L7FZDK6G.js";
|
|
4
4
|
import {
|
|
5
5
|
remarkDocumentationComponents
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-6WNFE2QG.js";
|
|
7
7
|
|
|
8
8
|
// src/mdx/index.ts
|
|
9
9
|
import { default as default2 } from "rehype-slug";
|
|
@@ -176,7 +176,36 @@ function rehypeDocumentationCode() {
|
|
|
176
176
|
return highlight(tree, ...args);
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
|
+
|
|
180
|
+
// src/mdx/export-markdown.ts
|
|
181
|
+
import remarkDirective from "remark-directive";
|
|
182
|
+
import remarkGfm from "remark-gfm";
|
|
183
|
+
import remarkMdx from "remark-mdx";
|
|
184
|
+
import remarkParse from "remark-parse";
|
|
185
|
+
import remarkStringify from "remark-stringify";
|
|
186
|
+
import { unified } from "unified";
|
|
187
|
+
function exportMarkdownBody(content, links) {
|
|
188
|
+
const processor = unified().use(remarkParse).use(remarkGfm).use(remarkDirective);
|
|
189
|
+
if (links.sourcePath.endsWith(".mdx")) processor.use(remarkMdx);
|
|
190
|
+
const exporter = processor.use(remarkStringify).use(() => (tree) => {
|
|
191
|
+
function strip(node) {
|
|
192
|
+
node.children = node.children?.filter(
|
|
193
|
+
(child) => !["mdxjsEsm", "mdxFlowExpression", "mdxTextExpression"].includes(
|
|
194
|
+
child.type
|
|
195
|
+
)
|
|
196
|
+
);
|
|
197
|
+
if (Array.isArray(node.attributes))
|
|
198
|
+
node.attributes = node.attributes.filter(
|
|
199
|
+
(attribute) => attribute.type !== "mdxJsxExpressionAttribute" && (typeof attribute.value !== "object" || attribute.value?.type !== "mdxJsxAttributeValueExpression")
|
|
200
|
+
);
|
|
201
|
+
node.children?.forEach(strip);
|
|
202
|
+
}
|
|
203
|
+
strip(tree);
|
|
204
|
+
}).use(remarkDocumentLinks, links);
|
|
205
|
+
return String(exporter.processSync(content));
|
|
206
|
+
}
|
|
179
207
|
export {
|
|
208
|
+
exportMarkdownBody,
|
|
180
209
|
rehypeDocumentationCode,
|
|
181
210
|
default2 as rehypeDocumentationHeadings,
|
|
182
211
|
remarkDocumentLinks,
|
package/dist/search/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "../chunk-FPBRKD4M.js";
|
|
4
4
|
import {
|
|
5
5
|
remarkDocumentationComponents
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-6WNFE2QG.js";
|
|
7
7
|
|
|
8
8
|
// src/search/index.ts
|
|
9
9
|
import GithubSlugger from "github-slugger";
|
|
@@ -68,7 +68,7 @@ function buildSearchIndex(documents) {
|
|
|
68
68
|
].includes(node.type)) {
|
|
69
69
|
if (node.name && ["script", "style", "svg"].includes(node.name.toLowerCase()))
|
|
70
70
|
return;
|
|
71
|
-
const nestedInteractive = interactive || node.name === "TabsContent" || node.name === "AccordionContent";
|
|
71
|
+
const nestedInteractive = interactive || node.name === "TabsContent" || node.name === "AccordionContent" || node.name === "Step";
|
|
72
72
|
if (node.name === "Callout") {
|
|
73
73
|
const title = node.attributes?.find(
|
|
74
74
|
(attribute) => attribute.type === "mdxJsxAttribute" && attribute.name === "title"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexibase/rdx-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Content indexing and document utilities for RDX documentation projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -53,14 +53,15 @@
|
|
|
53
53
|
"remark-gfm": "^4.0.1",
|
|
54
54
|
"remark-mdx": "^3.1.1",
|
|
55
55
|
"remark-parse": "^11.0.0",
|
|
56
|
+
"remark-stringify": "^11.0.0",
|
|
56
57
|
"unified": "^11.0.5",
|
|
57
|
-
"@lexibase/rdx-types": "2.
|
|
58
|
+
"@lexibase/rdx-types": "2.3.0"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@types/node": "^22.15.3",
|
|
61
62
|
"@types/react": "19.3.0",
|
|
62
|
-
"@rdx/
|
|
63
|
-
"@rdx/
|
|
63
|
+
"@rdx/eslint-config": "1.0.0",
|
|
64
|
+
"@rdx/typescript-config": "1.0.0"
|
|
64
65
|
},
|
|
65
66
|
"engines": {
|
|
66
67
|
"node": "^22.18.0 || ^24.11.0"
|