Skip to content

Commit 48d5cdc

Browse files
Copilothotlong
andcommitted
fix: Update fumadocs source mapping and add debugging for routes
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 81bd2fa commit 48d5cdc

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

apps/site/app/docs/[[...slug]]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export default async function Page({
1717
const page = source.getPage(slug);
1818
if (!page) notFound();
1919

20-
const MDX = page.data.body;
20+
const MDX = (page.data as any).body;
2121

2222
return (
23-
<DocsPage toc={page.data.toc} full={page.data.full}>
23+
<DocsPage toc={(page.data as any).toc} full={(page.data as any).full}>
2424
<DocsTitle>{page.data.title}</DocsTitle>
2525
<DocsDescription>{page.data.description}</DocsDescription>
2626
<DocsBody>
@@ -46,3 +46,4 @@ export async function generateMetadata(props: {
4646
description: page.data.description,
4747
};
4848
}
49+

apps/site/lib/source.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
import { docs } from '@/.source';
21
import { loader } from 'fumadocs-core/source';
3-
import { createMDXSource } from 'fumadocs-mdx';
2+
import { docs } from '@/.source';
3+
4+
// Map the docs from .source to the format expected by loader
5+
const mappedDocs = docs
6+
.filter((doc: any) => doc && doc.info && doc.info.path)
7+
.map((doc: any) => {
8+
let path = doc.info.path.replace(/\.mdx?$/, '');
9+
// Convert index.mdx to empty path
10+
if (path === 'index') path = '';
11+
12+
return {
13+
type: 'page' as const,
14+
path,
15+
data: {
16+
...doc.data,
17+
body: doc.data.default,
18+
},
19+
};
20+
});
421

522
export const source = loader({
623
baseUrl: '/docs',
7-
source: createMDXSource(docs, []),
24+
source: {
25+
files: mappedDocs,
26+
},
827
});

0 commit comments

Comments
 (0)