Skip to content

Commit 785fc24

Browse files
author
Rajat
committed
Reverting docs' next.config
1 parent 5502fac commit 785fc24

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

apps/docs/app/(home)/[[...slug]]/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export default async function Page(props: {
4242
}
4343

4444
const MDXContent = page.data.body;
45-
const markdownUrl = `${page.url === "/" ? "/index" : page.url}.mdx`;
45+
const markdownPath =
46+
page.url === "/" ? "index" : page.url.replace(/^\//, "");
47+
const markdownUrl = `/llms.mdx/${markdownPath}`;
4648
const githubBaseUrl =
4749
process.env.NEXT_PUBLIC_DOCS_GITHUB_BASE_URL ||
4850
"https://github.com/codelitdev/medialit/blob/main/apps/docs/content/docs";

apps/docs/app/[...slug].mdx/route.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ import { getLLMText } from "@/lib/get-llm-text";
44
export const revalidate = false;
55

66
export async function GET(
7-
req: Request,
8-
_ctx: { params: Promise<Record<string, string | string[]>> },
7+
_req: Request,
8+
{
9+
params,
10+
}: {
11+
params: Promise<{ slug?: string | string[] } | undefined>;
12+
},
913
) {
10-
const pathname = new URL(req.url).pathname;
11-
const relative = pathname.replace(/^\/+/, "").replace(/\.mdx$/, "");
12-
const slug = relative.length > 0 ? relative.split("/") : [];
14+
const rawSlug = (await params)?.slug;
15+
const slug = Array.isArray(rawSlug)
16+
? rawSlug
17+
: typeof rawSlug === "string"
18+
? [rawSlug]
19+
: ["index"];
1320
const normalizedSlug =
1421
slug.length === 1 && slug[0] === "index" ? undefined : slug;
1522
const page = source.getPage(normalizedSlug);

apps/docs/next.config.mjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { createMDX } from 'fumadocs-mdx/next';
2-
import { PHASE_DEVELOPMENT_SERVER } from "next/constants.js";
32

43
const withMDX = createMDX();
54

6-
/** @type {import('next').NextConfig | ((phase: string) => import('next').NextConfig)} */
7-
const config = (phase) => ({
5+
/** @type {import('next').NextConfig} */
6+
const config = {
87
reactStrictMode: true,
9-
...(phase === PHASE_DEVELOPMENT_SERVER ? {} : { output: "export" }),
8+
output: 'export',
109
images: {
1110
unoptimized: true,
12-
},
13-
});
11+
}
12+
};
1413

15-
export default withMDX(config);
14+
export default withMDX(config);

0 commit comments

Comments
 (0)