@vercel/geistdocs 2.15.3-canary.f771302 → 2.15.4
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/cli/index.js +1 -1
- package/dist/internal/mdx-to-markdown.d.ts.map +1 -1
- package/dist/internal/mdx-to-markdown.js +0 -9
- package/dist/internal/page-actions-client.js +1 -1
- package/dist/internal/page-actions.d.ts +4 -4
- package/dist/internal/page-actions.d.ts.map +1 -1
- package/dist/internal/page-actions.js +1 -6
- package/dist/mdx.d.ts +25 -3
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mdx.js +61 -8
- package/dist/mobile-docs-bar.js +1 -1
- package/dist/next.d.ts +1 -9
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +2 -25
- package/dist/pages/docs.d.ts +98 -5
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +250 -13
- package/dist/source-config.d.ts +1 -10
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +10 -20
- package/docs/agents.md +1 -1
- package/docs/llms.txt +1 -9
- package/docs/manifest.json +1 -1
- package/docs/pages/configuration.md +0 -8
- package/package.json +8 -28
- package/shared-theme.css +7 -1
- package/source-config.js +10 -24
- package/template/content/docs/configuration.mdx +0 -8
- package/template/package.json +1 -1
- package/dist/mdx-basic.d.ts +0 -27
- package/dist/mdx-basic.d.ts.map +0 -1
- package/dist/mdx-basic.js +0 -61
- package/dist/pages/docs-custom.d.ts +0 -111
- package/dist/pages/docs-custom.d.ts.map +0 -1
- package/dist/pages/docs-custom.js +0 -250
- package/native-mdx/LICENSE-mdxjs-rs +0 -22
- package/native-mdx/binaries/darwin-arm64.node +0 -0
- package/native-mdx/binaries/linux-x64-gnu.node +0 -0
- package/native-mdx/data-entry.d.mts +0 -15
- package/native-mdx/data-entry.mjs +0 -116
- package/native-mdx/data-projection.mjs +0 -205
- package/native-mdx/loader-data.cjs +0 -36
- package/native-mdx/loader-mdx.cjs +0 -9
- package/native-mdx/loader-mdx.mjs +0 -235
- package/native-mdx/native-binding.cjs +0 -25
- package/rehype-code-highlights.d.ts +0 -13
- package/rehype-code-highlights.js +0 -230
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { basename } from "node:path";
|
|
2
|
-
|
|
3
|
-
// Deliberately conservative, opt-in projection of an already compiled module.
|
|
4
|
-
// Compilation, frontmatter validation and user plugins run before this helper.
|
|
5
|
-
export const DATA_QUERY = "geistdocs-data";
|
|
6
|
-
|
|
7
|
-
// Preserve spelling/order/encoding of every other parameter so forwarding
|
|
8
|
-
// resolves to the same module identity as the original rendering request.
|
|
9
|
-
export function withoutDataQuery(resourceQuery = "") {
|
|
10
|
-
const parts = (
|
|
11
|
-
resourceQuery.startsWith("?") ? resourceQuery.slice(1) : resourceQuery
|
|
12
|
-
).split("&");
|
|
13
|
-
const kept = parts.filter(
|
|
14
|
-
(part) => !new URLSearchParams(part).has(DATA_QUERY)
|
|
15
|
-
);
|
|
16
|
-
return kept.some(Boolean) ? `?${kept.join("&")}` : "";
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const JSX_RUNTIME = /^react\/jsx-(?:dev-)?runtime$/;
|
|
20
|
-
|
|
21
|
-
function createClosedValidator(ast) {
|
|
22
|
-
const runtimeCalls = new Set();
|
|
23
|
-
const runtimeValues = new Set();
|
|
24
|
-
const bindings = new Set();
|
|
25
|
-
for (const node of ast.body) {
|
|
26
|
-
if (node.id) {
|
|
27
|
-
bindings.add(node.id.name);
|
|
28
|
-
}
|
|
29
|
-
const declaration = node.declaration ?? node;
|
|
30
|
-
for (const item of declaration.declarations ?? []) {
|
|
31
|
-
bindings.add(item.id.name);
|
|
32
|
-
}
|
|
33
|
-
if (node.type !== "ImportDeclaration") {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
for (const item of node.specifiers) {
|
|
37
|
-
bindings.add(item.local.name);
|
|
38
|
-
if (!JSX_RUNTIME.test(node.source.value)) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (["jsx", "jsxs", "jsxDEV"].includes(item.imported?.name)) {
|
|
42
|
-
runtimeCalls.add(item.local.name);
|
|
43
|
-
}
|
|
44
|
-
if (item.imported?.name === "Fragment") {
|
|
45
|
-
runtimeValues.add(item.local.name);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const closed = (node) => {
|
|
50
|
-
if (!node) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
switch (node.type) {
|
|
54
|
-
case "Literal":
|
|
55
|
-
return !node.regex;
|
|
56
|
-
case "Identifier":
|
|
57
|
-
return (
|
|
58
|
-
runtimeValues.has(node.name) ||
|
|
59
|
-
(node.name === "undefined" && !bindings.has("undefined"))
|
|
60
|
-
);
|
|
61
|
-
case "ArrayExpression":
|
|
62
|
-
return node.elements.every((item) => item === null || closed(item));
|
|
63
|
-
case "ObjectExpression":
|
|
64
|
-
return node.properties.every(
|
|
65
|
-
(item) =>
|
|
66
|
-
item.type === "Property" &&
|
|
67
|
-
item.kind === "init" &&
|
|
68
|
-
!item.method &&
|
|
69
|
-
!item.computed &&
|
|
70
|
-
closed(item.value)
|
|
71
|
-
);
|
|
72
|
-
case "UnaryExpression":
|
|
73
|
-
return (
|
|
74
|
-
["-", "+", "!", "void"].includes(node.operator) &&
|
|
75
|
-
closed(node.argument)
|
|
76
|
-
);
|
|
77
|
-
case "CallExpression":
|
|
78
|
-
return (
|
|
79
|
-
node.callee.type === "Identifier" &&
|
|
80
|
-
runtimeCalls.has(node.callee.name) &&
|
|
81
|
-
node.arguments.every(closed)
|
|
82
|
-
);
|
|
83
|
-
case "NewExpression":
|
|
84
|
-
return (
|
|
85
|
-
node.callee.name === "Date" &&
|
|
86
|
-
!bindings.has("Date") &&
|
|
87
|
-
node.arguments.length === 1 &&
|
|
88
|
-
node.arguments[0].type === "Literal"
|
|
89
|
-
);
|
|
90
|
-
default:
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
return closed;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function projectDataModule(code, parse) {
|
|
98
|
-
const fallback = (reason) => ({ code, projected: false, reason });
|
|
99
|
-
let ast;
|
|
100
|
-
try {
|
|
101
|
-
ast = parse(code, { ecmaVersion: "latest", sourceType: "module" });
|
|
102
|
-
} catch {
|
|
103
|
-
return fallback("unrecognized compiled syntax");
|
|
104
|
-
}
|
|
105
|
-
const closed = createClosedValidator(ast);
|
|
106
|
-
const kept = [];
|
|
107
|
-
let hasBody = false;
|
|
108
|
-
let hasFrontmatter = false;
|
|
109
|
-
for (const node of ast.body) {
|
|
110
|
-
switch (node.type) {
|
|
111
|
-
case "ImportDeclaration":
|
|
112
|
-
// Keep all imports, including component imports: their evaluation may
|
|
113
|
-
// have side effects. Let the bundler honor each package's sideEffects.
|
|
114
|
-
kept.push(code.slice(node.start, node.end));
|
|
115
|
-
break;
|
|
116
|
-
case "FunctionDeclaration":
|
|
117
|
-
case "EmptyStatement":
|
|
118
|
-
break;
|
|
119
|
-
case "ExportDefaultDeclaration":
|
|
120
|
-
if (
|
|
121
|
-
node.declaration.type !== "FunctionDeclaration" &&
|
|
122
|
-
!(
|
|
123
|
-
node.declaration.type === "Identifier" &&
|
|
124
|
-
ast.body.some(
|
|
125
|
-
(item) =>
|
|
126
|
-
item.type === "FunctionDeclaration" &&
|
|
127
|
-
item.id.name === node.declaration.name
|
|
128
|
-
)
|
|
129
|
-
)
|
|
130
|
-
) {
|
|
131
|
-
return fallback("non-function default export");
|
|
132
|
-
}
|
|
133
|
-
hasBody = true;
|
|
134
|
-
break;
|
|
135
|
-
case "ExportNamedDeclaration": {
|
|
136
|
-
const declaration = node.declaration;
|
|
137
|
-
if (declaration?.type !== "VariableDeclaration") {
|
|
138
|
-
return fallback("executable or re-exported metadata");
|
|
139
|
-
}
|
|
140
|
-
if (
|
|
141
|
-
declaration.declarations.some(
|
|
142
|
-
(item) => item.id.type !== "Identifier" || !closed(item.init)
|
|
143
|
-
)
|
|
144
|
-
) {
|
|
145
|
-
return fallback("metadata depends on executable code");
|
|
146
|
-
}
|
|
147
|
-
hasFrontmatter ||= declaration.declarations.some(
|
|
148
|
-
(item) => item.id.name === "frontmatter"
|
|
149
|
-
);
|
|
150
|
-
kept.push(code.slice(node.start, node.end));
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
default:
|
|
154
|
-
return fallback(`module evaluation requires ${node.type}`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (!(hasBody && hasFrontmatter)) {
|
|
158
|
-
return fallback("missing compiled MDX contract");
|
|
159
|
-
}
|
|
160
|
-
kept.push(
|
|
161
|
-
'export default function(){throw new Error("Data-only MDX cannot render a page; use the server entry.");}'
|
|
162
|
-
);
|
|
163
|
-
return { code: kept.join("\n"), projected: true, reason: null };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Compose with the existing loader rather than bypassing its compatibility gate.
|
|
167
|
-
// The delegate owns dependencies/config reloads and native-to-JS fallback.
|
|
168
|
-
export function createDataLoader(delegate, parse, onResult = () => undefined) {
|
|
169
|
-
return function dataLoader(source) {
|
|
170
|
-
const query = new URLSearchParams((this.resourceQuery ?? "").slice(1));
|
|
171
|
-
if (!query.has(DATA_QUERY)) {
|
|
172
|
-
return delegate.call(this, source);
|
|
173
|
-
}
|
|
174
|
-
const done = this.async();
|
|
175
|
-
const context = Object.create(this);
|
|
176
|
-
context.resourceQuery = withoutDataQuery(this.resourceQuery);
|
|
177
|
-
context.async = () => (error, code, _map, metadata) => {
|
|
178
|
-
if (error) {
|
|
179
|
-
return done(error);
|
|
180
|
-
}
|
|
181
|
-
let result;
|
|
182
|
-
try {
|
|
183
|
-
result = projectDataModule(code, parse);
|
|
184
|
-
if (!result.projected) {
|
|
185
|
-
// Reuse the canonical module instead of evaluating a second copy of
|
|
186
|
-
// authored MDX effects. This import still runs the full loader chain.
|
|
187
|
-
const request = JSON.stringify(
|
|
188
|
-
`./${basename(this.resourcePath)}${context.resourceQuery}${this.resourceFragment ?? ""}`
|
|
189
|
-
);
|
|
190
|
-
result = {
|
|
191
|
-
...result,
|
|
192
|
-
forwarded: true,
|
|
193
|
-
code: `export * from ${request};\nexport { default } from ${request};`,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
onResult({ filePath: this.resourcePath, ...result });
|
|
197
|
-
} catch (error) {
|
|
198
|
-
return done(error);
|
|
199
|
-
}
|
|
200
|
-
// Both projection and canonical forwarding invalidate the original map.
|
|
201
|
-
done(null, result.code, undefined, metadata);
|
|
202
|
-
};
|
|
203
|
-
return delegate.call(context, source);
|
|
204
|
-
};
|
|
205
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Experimental wrapper: point experimentalMdxLoader at this file. Ordinary MDX
|
|
4
|
-
// stays unchanged; only generated data-entry imports carry geistdocs-data=1.
|
|
5
|
-
module.exports = function loader(source) {
|
|
6
|
-
if (
|
|
7
|
-
!new URLSearchParams((this.resourceQuery ?? "").slice(1)).has(
|
|
8
|
-
"geistdocs-data"
|
|
9
|
-
)
|
|
10
|
-
) {
|
|
11
|
-
// Rendering-only workers should not load the projection parser at all.
|
|
12
|
-
return require("./loader-mdx.cjs").call(this, source);
|
|
13
|
-
}
|
|
14
|
-
const done = this.async();
|
|
15
|
-
import("./data-projection.mjs")
|
|
16
|
-
.then(({ createDataLoader }) => {
|
|
17
|
-
const { parse } = require("next/dist/compiled/acorn");
|
|
18
|
-
const delegate = require("./loader-mdx.cjs");
|
|
19
|
-
const context = Object.create(this);
|
|
20
|
-
context.async = () => done;
|
|
21
|
-
return createDataLoader(
|
|
22
|
-
delegate,
|
|
23
|
-
parse,
|
|
24
|
-
({ filePath, projected, forwarded = false, reason, code }) => {
|
|
25
|
-
// Optional diagnostics for validation builds, never enable when timing.
|
|
26
|
-
if (process.env.GEISTDOCS_DATA_REPORT) {
|
|
27
|
-
require("node:fs").appendFileSync(
|
|
28
|
-
process.env.GEISTDOCS_DATA_REPORT,
|
|
29
|
-
`${JSON.stringify({ filePath, projected, forwarded, reason, outputBytes: Buffer.byteLength(code) })}\n`
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
).call(context, source);
|
|
34
|
-
})
|
|
35
|
-
.catch(done);
|
|
36
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// CommonJS entry for Turbopack/webpack, like fumadocs-mdx's own shim.
|
|
3
|
-
module.exports = function loader(source) {
|
|
4
|
-
const callback = this.async();
|
|
5
|
-
import("./loader-mdx.mjs").then(
|
|
6
|
-
(mod) => mod.run.call(this, source, callback),
|
|
7
|
-
callback
|
|
8
|
-
);
|
|
9
|
-
};
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
// Webpack/Turbopack loader for MDX, backed by the native fumadocs-mdx-rs
|
|
2
|
-
// compiler. Mirrors fumadocs-mdx's `createMdxLoader`: config, collection,
|
|
3
|
-
// frontmatter validation, and doc plugins stay in JS (they're user code);
|
|
4
|
-
// parsing, transforms, highlighting, and codegen run natively. Files that
|
|
5
|
-
// use something the native pipeline doesn't cover go to fumadocs-mdx.
|
|
6
|
-
import { createHash } from "node:crypto";
|
|
7
|
-
import { readFile } from "node:fs/promises";
|
|
8
|
-
import { createRequire } from "node:module";
|
|
9
|
-
import path from "node:path";
|
|
10
|
-
import { pathToFileURL } from "node:url";
|
|
11
|
-
|
|
12
|
-
// fumadocs-mdx 14.0.4 internals (not in its public exports).
|
|
13
|
-
const fumadocsDist = path.dirname(
|
|
14
|
-
new URL(import.meta.resolve("fumadocs-mdx")).pathname
|
|
15
|
-
);
|
|
16
|
-
const internal = (chunk) =>
|
|
17
|
-
import(pathToFileURL(path.join(fumadocsDist, chunk)).href);
|
|
18
|
-
const { fumaMatter } = await internal("chunk-VWJKRQZR.js");
|
|
19
|
-
const { getCore } = await internal("chunk-CGGDM5F3.js");
|
|
20
|
-
const { createStandaloneConfigLoader } = await internal("chunk-NKIL543T.js");
|
|
21
|
-
|
|
22
|
-
const require = createRequire(import.meta.url);
|
|
23
|
-
const native = require(
|
|
24
|
-
process.env.FUMADOCS_MDX_RS_BINARY ?? "./native-binding.cjs"
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
let configLoader;
|
|
28
|
-
let jsLoader;
|
|
29
|
-
let compiledConfigIdentity;
|
|
30
|
-
const compatibility = new WeakMap();
|
|
31
|
-
|
|
32
|
-
// The plugin list the native pipeline implements: Geistdocs' defaults with
|
|
33
|
-
// Highlights (`defineGeistdocsSourceConfig()`), in fumadocs-mdx's order.
|
|
34
|
-
const NATIVE_REMARK = [
|
|
35
|
-
["remarkGfm"],
|
|
36
|
-
["remarkSteps"],
|
|
37
|
-
["remarkHeading", { generateToc: false }],
|
|
38
|
-
["remarkImage", { useImport: true }],
|
|
39
|
-
["remarkCodeTab"],
|
|
40
|
-
["remarkNpm"],
|
|
41
|
-
["remarkMdxMermaid"],
|
|
42
|
-
["remarkDetails"],
|
|
43
|
-
["remarkStructure", { exportAs: "structuredData" }],
|
|
44
|
-
];
|
|
45
|
-
const NATIVE_REHYPE = [
|
|
46
|
-
["rehypeCodeHighlights"],
|
|
47
|
-
["rehypeTaskListLabels"],
|
|
48
|
-
["rehypeToc"],
|
|
49
|
-
];
|
|
50
|
-
const NATIVE_OPTION_KEYS = new Set([
|
|
51
|
-
"remarkPlugins",
|
|
52
|
-
"rehypePlugins",
|
|
53
|
-
"outputFormat",
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
const samePlugins = (actual, expected) =>
|
|
57
|
-
actual.length === expected.length &&
|
|
58
|
-
actual.every((entry, index) => {
|
|
59
|
-
const [plugin, options] = Array.isArray(entry) ? entry : [entry];
|
|
60
|
-
const [name, expectedOptions] = expected[index];
|
|
61
|
-
if (plugin?.name !== name) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
if (name === "rehypeCodeHighlights") {
|
|
65
|
-
// Geistdocs forces the theme; any other option changes the output.
|
|
66
|
-
return Object.keys(options ?? {}).every(
|
|
67
|
-
(key) => key === "themes" || key === "defaultColor"
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
return (
|
|
71
|
-
JSON.stringify(options ?? {}) === JSON.stringify(expectedOptions ?? {})
|
|
72
|
-
);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
/** Why a collection's MDX options need the JS pipeline, if they do. */
|
|
76
|
-
async function incompatibility(config, collection) {
|
|
77
|
-
// Collection names survive config reloads; compatibility decisions must not.
|
|
78
|
-
if (!compatibility.has(config)) {
|
|
79
|
-
compatibility.set(config, new Map());
|
|
80
|
-
}
|
|
81
|
-
const reasons = compatibility.get(config);
|
|
82
|
-
const key = collection?.name ?? "global";
|
|
83
|
-
if (!reasons.has(key)) {
|
|
84
|
-
const options = await config.getMDXOptions(collection, "bundler");
|
|
85
|
-
let reason = null;
|
|
86
|
-
const extraKeys = Object.keys(options).filter(
|
|
87
|
-
(k) => !NATIVE_OPTION_KEYS.has(k)
|
|
88
|
-
);
|
|
89
|
-
if (extraKeys.length > 0) {
|
|
90
|
-
reason = `MDX options: ${extraKeys.join(", ")}`;
|
|
91
|
-
} else if (!samePlugins(options.remarkPlugins ?? [], NATIVE_REMARK)) {
|
|
92
|
-
reason = "custom remark plugins";
|
|
93
|
-
} else if (!samePlugins(options.rehypePlugins ?? [], NATIVE_REHYPE)) {
|
|
94
|
-
reason = "custom rehype plugins or Shiki";
|
|
95
|
-
}
|
|
96
|
-
reasons.set(key, reason);
|
|
97
|
-
}
|
|
98
|
-
return reasons.get(key);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** The doc collection behind a `doc` or `docs` collection. */
|
|
102
|
-
const docCollectionOf = (collection) => {
|
|
103
|
-
if (collection?.type === "doc") {
|
|
104
|
-
return collection;
|
|
105
|
-
}
|
|
106
|
-
if (collection?.type === "docs") {
|
|
107
|
-
return collection.docs;
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
async function fallback({ source, development, query, compiler, filePath }) {
|
|
112
|
-
jsLoader ??= (await internal("chunk-USWQVJWR.js")).createMdxLoader(
|
|
113
|
-
configLoader
|
|
114
|
-
);
|
|
115
|
-
const out = await jsLoader.load({
|
|
116
|
-
getSource: () => source,
|
|
117
|
-
development,
|
|
118
|
-
query,
|
|
119
|
-
compiler,
|
|
120
|
-
filePath,
|
|
121
|
-
});
|
|
122
|
-
return out.code;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const literal = (value) => {
|
|
126
|
-
if (value instanceof Date) {
|
|
127
|
-
return `new Date(${JSON.stringify(value.toISOString())})`;
|
|
128
|
-
}
|
|
129
|
-
if (value === undefined) {
|
|
130
|
-
return "undefined";
|
|
131
|
-
}
|
|
132
|
-
return JSON.stringify(value);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export async function load({
|
|
136
|
-
source,
|
|
137
|
-
filePath,
|
|
138
|
-
query,
|
|
139
|
-
development,
|
|
140
|
-
compiler,
|
|
141
|
-
options,
|
|
142
|
-
}) {
|
|
143
|
-
if (development) {
|
|
144
|
-
// Imported settings can change the bundled config without changing the
|
|
145
|
-
// source config's mtime, which is all Fumadocs checks for reloads.
|
|
146
|
-
const compiled = await readFile(options.absoluteCompiledConfigPath);
|
|
147
|
-
const identity = createHash("sha256").update(compiled).digest("hex");
|
|
148
|
-
if (identity !== compiledConfigIdentity) {
|
|
149
|
-
compiledConfigIdentity = identity;
|
|
150
|
-
configLoader = undefined;
|
|
151
|
-
jsLoader = undefined;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
configLoader ??= createStandaloneConfigLoader({
|
|
155
|
-
core: getCore(options),
|
|
156
|
-
buildConfig: false,
|
|
157
|
-
mode: development ? "dev" : "production",
|
|
158
|
-
});
|
|
159
|
-
const core = configLoader.core;
|
|
160
|
-
const config = await configLoader.getConfig();
|
|
161
|
-
const matter = fumaMatter(source);
|
|
162
|
-
const collection = query.collection
|
|
163
|
-
? config.getCollection(query.collection)
|
|
164
|
-
: undefined;
|
|
165
|
-
const docCollection = docCollectionOf(collection);
|
|
166
|
-
if (docCollection) {
|
|
167
|
-
matter.data = await core.transformFrontmatter(
|
|
168
|
-
{ collection: docCollection, filePath, source },
|
|
169
|
-
matter.data
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
if (query.only === "frontmatter") {
|
|
173
|
-
return `export const frontmatter = ${JSON.stringify(matter.data)}`;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (await incompatibility(config, docCollection)) {
|
|
177
|
-
return fallback({ source, development, query, compiler, filePath });
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const result = native.compile(
|
|
181
|
-
matter.content,
|
|
182
|
-
JSON.stringify(matter.data ?? {}),
|
|
183
|
-
{
|
|
184
|
-
filePath,
|
|
185
|
-
includeProcessedMarkdown:
|
|
186
|
-
docCollection?.postprocess?.includeProcessedMarkdown === true,
|
|
187
|
-
development,
|
|
188
|
-
}
|
|
189
|
-
);
|
|
190
|
-
if (result.fallback) {
|
|
191
|
-
return fallback({ source, development, query, compiler, filePath });
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Doc plugins (e.g. last-modified) contribute extra exports.
|
|
195
|
-
let code = result.code;
|
|
196
|
-
if (docCollection) {
|
|
197
|
-
const file = await core.transformVFile(
|
|
198
|
-
{ collection: docCollection, filePath, source },
|
|
199
|
-
{ data: {}, path: filePath, value: source }
|
|
200
|
-
);
|
|
201
|
-
for (const { name, value } of file.data["mdx-export"] ?? []) {
|
|
202
|
-
code += `\nexport let ${name} = ${literal(value)};`;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return code;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/** Webpack loader entry. */
|
|
209
|
-
export default function loader(source) {
|
|
210
|
-
return run.call(this, source, this.async());
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/** Loader body with an explicit callback (used by the CJS shim). */
|
|
214
|
-
export async function run(source, callback) {
|
|
215
|
-
const options = this.getOptions();
|
|
216
|
-
this.cacheable(true);
|
|
217
|
-
this.addDependency(options.absoluteCompiledConfigPath);
|
|
218
|
-
try {
|
|
219
|
-
const query = Object.fromEntries(
|
|
220
|
-
new URLSearchParams(this.resourceQuery.slice(1))
|
|
221
|
-
);
|
|
222
|
-
const code = await load({
|
|
223
|
-
source,
|
|
224
|
-
filePath: this.resourcePath,
|
|
225
|
-
query,
|
|
226
|
-
development: this.mode === "development",
|
|
227
|
-
compiler: this,
|
|
228
|
-
options,
|
|
229
|
-
});
|
|
230
|
-
callback(undefined, code);
|
|
231
|
-
} catch (error) {
|
|
232
|
-
error.message = `${path.relative(this.context, this.resourcePath)}: ${error.message}`;
|
|
233
|
-
callback(error);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { existsSync } = require("node:fs");
|
|
4
|
-
const path = require("node:path");
|
|
5
|
-
|
|
6
|
-
const local = path.join(__dirname, "fumadocs-mdx-rs.node");
|
|
7
|
-
const platform = `${process.platform}-${process.arch}${process.platform === "linux" ? "-gnu" : ""}`;
|
|
8
|
-
const bundled = path.join(__dirname, "binaries", `${platform}.node`);
|
|
9
|
-
|
|
10
|
-
if (existsSync(local)) {
|
|
11
|
-
module.exports = require(local);
|
|
12
|
-
} else {
|
|
13
|
-
if (
|
|
14
|
-
!existsSync(bundled) ||
|
|
15
|
-
(process.platform === "linux" &&
|
|
16
|
-
!process.report.getReport().header.glibcVersionRuntime)
|
|
17
|
-
) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
`This Geistdocs native MDX canary has no binary for ${platform}. ` +
|
|
20
|
-
"Supported: macOS arm64 and Linux x64 (glibc). " +
|
|
21
|
-
"Remove experimentalMdxLoader to use the JS compiler."
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
module.exports = require(bundled);
|
|
25
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { RehypeCodeOptions } from "fumadocs-core/mdx-plugins";
|
|
2
|
-
import type { Root } from "hast";
|
|
3
|
-
|
|
4
|
-
/** Zed-format Geist theme for @pierre/highlights, using Geist's Shiki CSS variables. */
|
|
5
|
-
export declare const geistHighlightsTheme: Record<string, unknown>;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Experimental drop-in for Fumadocs' `rehypeCode` that tokenizes with
|
|
9
|
-
* @pierre/highlights while keeping Shiki's HAST output and transformers.
|
|
10
|
-
*/
|
|
11
|
-
export declare const rehypeCodeHighlights: (
|
|
12
|
-
options?: Partial<RehypeCodeOptions>
|
|
13
|
-
) => (tree: Root, file: unknown) => Promise<void>;
|