@docubook/flame 1.7.2 → 2.0.0-alpha.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/.docu/components/Context.tsx +1 -1
- package/.docu/components/Pagination.tsx +9 -1
- package/.docu/components/Search.tsx +6 -6
- package/.docu/components/Sidebar.tsx +37 -8
- package/.docu/components/Theme.tsx +2 -2
- package/.docu/components/Toc.tsx +52 -6
- package/.docu/components/Typography.tsx +1 -1
- package/.docu/components/home/Hero.tsx +4 -4
- package/.docu/components/registry.ts +1 -1
- package/.docu/lib/build.deno.js +3 -3
- package/.docu/lib/{build.impl-TSIF3F7O.js → build.impl-VXB4KL4D.js} +3 -3
- package/.docu/lib/build.node.js +3 -3
- package/.docu/lib/{chunk-SPHVBXRR.js → chunk-7PRQ3RQB.js} +6 -6
- package/.docu/lib/{chunk-DITXUPUV.js → chunk-A6FIEG3H.js} +61 -10
- package/.docu/lib/{chunk-PJIJEPNR.js → chunk-JRERMREW.js} +5 -4
- package/.docu/lib/{chunk-KMDGSD57.js → chunk-LZDEWK25.js} +3 -3
- package/.docu/lib/{chunk-HRO7ONJQ.js → chunk-MQWWCO6O.js} +70 -27
- package/.docu/lib/{chunk-B6LGUADD.js → chunk-TRT6WQZG.js} +346 -183
- package/.docu/lib/chunk-UISOJ4RW.js +114 -0
- package/.docu/lib/clean.js +1 -1
- package/.docu/lib/deploy.deno.js +1 -1
- package/.docu/lib/deploy.node.js +1 -1
- package/.docu/lib/preview.deno.js +5 -3
- package/.docu/lib/preview.node.js +5 -3
- package/.docu/lib/server.deno.js +6 -4
- package/.docu/lib/server.node.js +6 -4
- package/.docu/node/build.impl.ts +75 -26
- package/.docu/node/build.ts +70 -17
- package/.docu/node/client.ts +64 -27
- package/.docu/node/deploy.shared.ts +5 -5
- package/.docu/node/deploy.ts +1 -1
- package/.docu/node/html.shared.ts +7 -2
- package/.docu/node/html.ts +4 -2
- package/.docu/node/hydrate.node.ts +69 -4
- package/.docu/node/hydrate.ts +50 -1
- package/.docu/node/mdx-manifest.d.ts +5 -0
- package/.docu/node/mdx.ts +103 -17
- package/.docu/node/preview.deno.ts +1 -1
- package/.docu/node/preview.impl.ts +3 -3
- package/.docu/node/preview.node.ts +1 -1
- package/.docu/node/preview.ts +2 -2
- package/.docu/node/route.ts +57 -1
- package/.docu/node/runtime/bun.ts +28 -0
- package/.docu/node/runtime/deno.ts +34 -0
- package/.docu/node/runtime/index.ts +4 -0
- package/.docu/node/runtime/node.ts +107 -0
- package/.docu/node/runtime/types.ts +19 -0
- package/.docu/node/search-indexer.ts +3 -2
- package/.docu/node/seo.ts +2 -2
- package/.docu/node/server-routes.ts +32 -13
- package/.docu/node/server.deno.ts +1 -1
- package/.docu/node/server.impl.ts +49 -3
- package/.docu/node/server.node.ts +1 -1
- package/.docu/node/server.ts +45 -1
- package/.docu/pages/docs/[[...slug]].tsx +13 -4
- package/.docu/pages/index.tsx +1 -1
- package/.docu/styles/globals.css +38 -20
- package/README.md +7 -48
- package/bin/cli.js +25 -7
- package/package.json +7 -6
- package/template/README.md +7 -48
- package/template/docs/getting-started/configuration.mdx +16 -4
- package/template/docs/getting-started/overview.mdx +34 -42
- package/template/docs/guide/components.mdx +46 -228
- package/template/docs/guide/routing.mdx +8 -6
- package/template/docs/index.mdx +9 -8
- package/template/docu.json +4 -4
|
@@ -7,13 +7,15 @@ import {
|
|
|
7
7
|
buildClientBundle,
|
|
8
8
|
captureException,
|
|
9
9
|
compileMdx,
|
|
10
|
+
compileMdxModule,
|
|
10
11
|
computeInlineThemeCss,
|
|
12
|
+
frontmatterField,
|
|
11
13
|
generateSearchIndex,
|
|
12
14
|
getGitLastModifiedBatch,
|
|
13
15
|
htmlShell,
|
|
14
16
|
initSentry,
|
|
15
17
|
loadPlugins
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-TRT6WQZG.js";
|
|
17
19
|
import {
|
|
18
20
|
cspHeader,
|
|
19
21
|
generateNonce,
|
|
@@ -21,7 +23,7 @@ import {
|
|
|
21
23
|
} from "./chunk-EOK6KATZ.js";
|
|
22
24
|
import {
|
|
23
25
|
logger
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-JRERMREW.js";
|
|
25
27
|
import {
|
|
26
28
|
ASSETS_DIR,
|
|
27
29
|
CACHE_FILE,
|
|
@@ -48,7 +50,7 @@ function buildSeoMeta(config, frontmatter, slug) {
|
|
|
48
50
|
url,
|
|
49
51
|
siteName: config.meta?.title || ""
|
|
50
52
|
};
|
|
51
|
-
const image =
|
|
53
|
+
const image = frontmatterField(frontmatter, "image") || config.meta?.ogImage;
|
|
52
54
|
if (image) {
|
|
53
55
|
try {
|
|
54
56
|
result.image = new URL(image, image.startsWith("/") ? baseURL : `${baseURL}/docs/`).href;
|
|
@@ -121,8 +123,8 @@ ${msg}`, { cause: err });
|
|
|
121
123
|
content
|
|
122
124
|
});
|
|
123
125
|
}
|
|
124
|
-
const title = (
|
|
125
|
-
const description =
|
|
126
|
+
const title = frontmatterField(frontmatter, "title") || slug || "Docs";
|
|
127
|
+
const description = frontmatterField(frontmatter, "description");
|
|
126
128
|
const slugParts = slug ? slug.split("/") : [];
|
|
127
129
|
const page = React.createElement(
|
|
128
130
|
DocsLayout,
|
|
@@ -131,12 +133,15 @@ ${msg}`, { cause: err });
|
|
|
131
133
|
slug: slugParts,
|
|
132
134
|
title,
|
|
133
135
|
description,
|
|
134
|
-
date: frontmatter
|
|
135
|
-
content:
|
|
136
|
+
date: frontmatterField(frontmatter, "date") || void 0,
|
|
137
|
+
// Render MDX content as its own root: client hydrates the island as a
|
|
138
|
+
// separate root, so SSR must be root-relative too or useId-based ids
|
|
139
|
+
// (mdx-compiler components) mismatch during hydration.
|
|
140
|
+
content: renderToString(result.content),
|
|
136
141
|
tocs: result.tocs,
|
|
137
142
|
filePath,
|
|
138
143
|
repoUrl: docuConfig.repo?.url,
|
|
139
|
-
|
|
144
|
+
mdxSlug: slug
|
|
140
145
|
})
|
|
141
146
|
);
|
|
142
147
|
const body = renderToString(page);
|
|
@@ -146,7 +151,7 @@ ${msg}`, { cause: err });
|
|
|
146
151
|
const depth = slug ? slug.split("/").length : 1;
|
|
147
152
|
const favicon = docuConfig.meta?.favicon || "/docs/assets/images/favicon.ico";
|
|
148
153
|
const seo = buildSeoMeta(docuConfig, frontmatter, slug || "");
|
|
149
|
-
const csp = cspHeader(nonce
|
|
154
|
+
const csp = cspHeader(nonce);
|
|
150
155
|
let html = htmlShell({
|
|
151
156
|
title,
|
|
152
157
|
description,
|
|
@@ -200,9 +205,55 @@ async function runBuild() {
|
|
|
200
205
|
const cache = args.force ? {} : await readCache();
|
|
201
206
|
let built = 0;
|
|
202
207
|
let skipped = 0;
|
|
208
|
+
const pluginsConfig = docuConfig.plugins ?? [];
|
|
209
|
+
const builder = pluginsConfig.length > 0 ? new BuildPluginBuilder(docuConfig) : null;
|
|
210
|
+
if (builder) {
|
|
211
|
+
const plugins = await loadPlugins(pluginsConfig);
|
|
212
|
+
for (const plugin of plugins) {
|
|
213
|
+
await plugin.setup(builder);
|
|
214
|
+
}
|
|
215
|
+
await builder.runOnStart();
|
|
216
|
+
}
|
|
217
|
+
const mdxSources = {};
|
|
218
|
+
const prePassTasks = mdxFiles.map(async (file) => {
|
|
219
|
+
let raw;
|
|
220
|
+
try {
|
|
221
|
+
raw = await readFile(file.absPath, "utf-8");
|
|
222
|
+
} catch {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
let content = raw;
|
|
226
|
+
if (builder) {
|
|
227
|
+
const relPath = file.absPath.replace(PROJECT_ROOT + "/", "");
|
|
228
|
+
const transformed = await builder.runOnLoad(relPath, content);
|
|
229
|
+
if (transformed?.contents) content = transformed.contents;
|
|
230
|
+
}
|
|
231
|
+
const remarkPlugins = builder?.collectRemarkPlugins();
|
|
232
|
+
const rehypePlugins = builder?.collectRehypePlugins();
|
|
233
|
+
mdxSources[file.path] = await compileMdxModule(content, remarkPlugins, rehypePlugins);
|
|
234
|
+
});
|
|
235
|
+
await Promise.all(prePassTasks);
|
|
236
|
+
const indexMdxPath = join(DOCS_DIR, "index.mdx");
|
|
237
|
+
if (existsSync(indexMdxPath)) {
|
|
238
|
+
try {
|
|
239
|
+
const indexRaw = await readFile(indexMdxPath, "utf-8");
|
|
240
|
+
let indexContent = indexRaw;
|
|
241
|
+
if (builder) {
|
|
242
|
+
const relPath = indexMdxPath.replace(PROJECT_ROOT + "/", "");
|
|
243
|
+
const transformed = await builder.runOnLoad(relPath, indexContent);
|
|
244
|
+
if (transformed?.contents) indexContent = transformed.contents;
|
|
245
|
+
}
|
|
246
|
+
mdxSources[""] = await compileMdxModule(
|
|
247
|
+
indexContent,
|
|
248
|
+
builder?.collectRemarkPlugins(),
|
|
249
|
+
builder?.collectRehypePlugins()
|
|
250
|
+
);
|
|
251
|
+
} catch {
|
|
252
|
+
}
|
|
253
|
+
}
|
|
203
254
|
logger.bundleStart();
|
|
204
255
|
let t = performance.now();
|
|
205
|
-
assetManifest = await buildClientBundle();
|
|
256
|
+
assetManifest = await buildClientBundle(mdxSources);
|
|
206
257
|
logger.bundleDone(Math.round(performance.now() - t));
|
|
207
258
|
inlineThemeCss = computeInlineThemeCss();
|
|
208
259
|
const lastManifest = cache["__assets__"];
|
|
@@ -214,15 +265,6 @@ async function runBuild() {
|
|
|
214
265
|
builtAt: Date.now()
|
|
215
266
|
};
|
|
216
267
|
}
|
|
217
|
-
const pluginsConfig = docuConfig.plugins ?? [];
|
|
218
|
-
const builder = pluginsConfig.length > 0 ? new BuildPluginBuilder(docuConfig) : null;
|
|
219
|
-
if (builder) {
|
|
220
|
-
const plugins = await loadPlugins(pluginsConfig);
|
|
221
|
-
for (const plugin of plugins) {
|
|
222
|
-
await plugin.setup(builder);
|
|
223
|
-
}
|
|
224
|
-
await builder.runOnStart();
|
|
225
|
-
}
|
|
226
268
|
logger.spinner.start("Building pages...");
|
|
227
269
|
t = performance.now();
|
|
228
270
|
const allRelPaths = mdxFiles.map((f) => f.absPath.replace(PROJECT_ROOT + "/", ""));
|
|
@@ -301,9 +343,9 @@ async function runBuild() {
|
|
|
301
343
|
await Promise.all(buildTasks.slice(i, i + CONCURRENCY).map((fn) => fn()));
|
|
302
344
|
}
|
|
303
345
|
try {
|
|
304
|
-
const
|
|
305
|
-
const indexRaw = await readFile(
|
|
306
|
-
const indexRelPath =
|
|
346
|
+
const indexMdxPath2 = join(DOCS_DIR, "index.mdx");
|
|
347
|
+
const indexRaw = await readFile(indexMdxPath2, "utf-8");
|
|
348
|
+
const indexRelPath = indexMdxPath2.replace(PROJECT_ROOT + "/", "");
|
|
307
349
|
const indexHtml = await renderDocsPage(
|
|
308
350
|
docuConfig,
|
|
309
351
|
"",
|
|
@@ -332,8 +374,7 @@ async function runBuild() {
|
|
|
332
374
|
body: renderToString(landingPage),
|
|
333
375
|
favicon: landingFavicon,
|
|
334
376
|
seo: landingSeo,
|
|
335
|
-
|
|
336
|
-
csp: cspHeader(landingNonce, true),
|
|
377
|
+
csp: cspHeader(landingNonce),
|
|
337
378
|
css: assetManifest.css,
|
|
338
379
|
js: assetManifest.js,
|
|
339
380
|
nonce: landingNonce,
|
|
@@ -353,12 +394,14 @@ async function runBuild() {
|
|
|
353
394
|
body: renderToString(notFoundPage),
|
|
354
395
|
favicon: notFoundFavicon,
|
|
355
396
|
headExtra: ['<meta name="robots" content="noindex,follow">'],
|
|
356
|
-
|
|
357
|
-
csp: cspHeader(notFoundNonce, true),
|
|
397
|
+
csp: cspHeader(notFoundNonce),
|
|
358
398
|
css: assetManifest.css,
|
|
359
399
|
js: assetManifest.js,
|
|
360
400
|
nonce: notFoundNonce,
|
|
361
|
-
themeCss: inlineThemeCss
|
|
401
|
+
themeCss: inlineThemeCss,
|
|
402
|
+
// Served as the static-host fallback at ANY requested path — relative
|
|
403
|
+
// depth can never be right there, so use root-absolute asset URLs.
|
|
404
|
+
absoluteAssets: true
|
|
362
405
|
});
|
|
363
406
|
await writeFile(join(DIST_DIR, "404.html"), notFoundHtml);
|
|
364
407
|
logger.spinner.stop(
|