Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions apps/docs/app/[lang]/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,7 @@ export default async function Page(props: {
const page = source.getPage(params.slug ?? [], params.lang);
if (!page) notFound();

// `async: true` on the docs collection makes the compiled body and toc
// load on demand instead of being statically imported, so they are awaited
// here. Frontmatter (`title`, `description`, `full`) stays eager.
const loaded = await page.data.load();
const MDX = loaded.body;
const MDX = page.data.body;

// Resolved once and handed to both controls, so they cannot drift apart and
// so a third control added below inherits the locale-independent URL instead
Expand Down Expand Up @@ -287,7 +283,7 @@ export default async function Page(props: {
dangerouslySetInnerHTML={{ __html: jsonLdHtml(item) }}
/>
))}
<DocsPage toc={loaded.toc} full={page.data.full}>
<DocsPage toc={page.data.toc} full={page.data.full}>
<DocsTitle>{page.data.title}</DocsTitle>
<DocsDescription className="mb-0">{page.data.description}</DocsDescription>
<div className="flex flex-row gap-2 items-center border-b pb-6">
Expand Down
23 changes: 0 additions & 23 deletions apps/docs/source.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,6 @@ import path from 'node:path';
export const docs = defineDocs({
dir: path.resolve(process.cwd(), '../../content/docs'),
docs: {
/**
* Load each page's compiled body on demand instead of statically importing
* all of them into every server entrypoint.
*
* Without this, `fumadocs-mdx:collections/server` eagerly imports all 397
* `.mdx` files, so every route that touches `source` — the docs page, but
* also `/llms.txt`, `/llms-full.txt`, `/llms.mdx/*`, `/og/*`, `/api/search`
* and `/sitemap.xml` — pulls the entire corpus into its own chunk. The
* bundler then inlined the whole set five times over into one worker:
* 2.50 MiB of authored MDX became a 100.93 MiB `handler.mjs`, and
* Cloudflare rejects any Worker over 64 MiB uncompressed (`code: 10027`).
*
* The multiplier, not the corpus, was the problem: measured on the same
* tree, one probe sentence from a single English page appeared 15 times in
* the bundle before this flag and 6 times after, taking `handler.mjs` from
* 100.93 MiB to 48.47 MiB.
*
* The cost is that `page.data.body` and `page.data.toc` become
* `page.data.load()`. Frontmatter stays eager, so `title`, `description`,
* `seoTitle` and `full` are unaffected, and `getText('processed')` — what
* the llms.txt routes call — is still a method on the entry.
*/
async: true,
schema: pageSchema.extend({
/**
* Optional SEO title: what the `<title>` tag should say, when that is not
Expand Down