You can modify the default Fumadocs setup to allow any documentation directly under the root. Follow these steps:
Move the page.tsx
from the home folder into the root folder. You can move the HomeLayout
from (home)/layout
directly into this page and wrap the existing homepage with it (something like this):
import Link from "next/link";
import { HomeLayout } from "fumadocs-ui/layouts/home";
import { baseOptions } from "@/lib/layout.shared";
export default function HomePage() {
return (
<HomeLayout {...baseOptions()}>
<main className="flex flex-1 flex-col justify-center text-center">
<h1 className="mb-4 text-2xl font-bold">Hello World</h1>
<p className="text-fd-muted-foreground">
You can open{" "}
<Link
href="/docs"
className="text-fd-foreground font-semibold underline"
>
/docs
</Link>{" "}
and see the documentation.
</p>
</main>
</HomeLayout>
);
}
Change the source to point to /
instead of /docs
:
export const source = loader({
baseUrl: "/",
source: docs.toFumadocsSource(),
});
Move /docs/[[...slug]]
to /[...slug]
.
Move /docs/layout.tsx
to /[...slug]/layout.tsx
.
You should then end up with the following structure:
│ global.css
│ layout.tsx
│ page.tsx
│
├─api
│ └─search
│ route.ts
│
└─[...slug]
layout.tsx
page.tsx