Skip to content

Commit

Permalink
Docs: Add guide for static export
Browse files Browse the repository at this point in the history
  • Loading branch information
fuma-nama committed Dec 20, 2024
1 parent b48f12c commit cc80f5b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 78 deletions.
12 changes: 6 additions & 6 deletions apps/docs/content/docs/mdx/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ const config = {
export default withMDX(config);
```

<Callout title="ESM Only" type='warn' className="mt-4">

The Next.js config must be a `.mjs` file since Fumadocs is ESM-only.

</Callout>

### Defining Collections

**Collection** refers to a collection containing a certain type of files, there's two types of collections:
Expand Down Expand Up @@ -116,12 +122,6 @@ Once you run `next dev` or `next build`, it generates a `.source` folder in root

The folder contains all output data and its types, you should add it to `.gitignore`.

<Callout title="ESM Only" type='warn' className="mt-4">

The Next.js config must be a `.mjs` file since Fumadocs is ESM-only.

</Callout>

The `fumadocs-mdx` command generates types for `.source` folder without running Next.js, you can add it as a post install script.

```json title="package.json"
Expand Down
3 changes: 1 addition & 2 deletions apps/docs/content/docs/mdx/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"---Features---",
"last-modified",
"image",
"manifest",
"!transform"
"manifest"
]
}
69 changes: 0 additions & 69 deletions apps/docs/content/docs/mdx/transform.mdx

This file was deleted.

1 change: 1 addition & 0 deletions apps/docs/content/docs/ui/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"...",
"---Setup---",
"manual-installation",
"static-export",
"(integrations)",
"---Writing---",
"markdown",
Expand Down
24 changes: 24 additions & 0 deletions apps/docs/content/docs/ui/static-export.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: Static Export
description: Enable static export with Fumadocs
---

## Overview

Fumadocs is fully compatible with Next.js static export, allowing you to export the app as a static HTML site without a Node.js server.

```js title="next.config.mjs"
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: 'export',
};
```

### Search

The search functionality of Fumadocs rely on route handlers, which is not supported by static export.

With the default search powered by Orama, you can build the search indexes statically following the [Orama Search](/docs/headless/search/orama#static-export) guide.
This allows the route handler to be statically cached into a single file, and search will be computed on browser instead.
2 changes: 1 addition & 1 deletion packages/ui/src/components/layout/toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function Toc(props: HTMLAttributes<HTMLDivElement>) {
} as object
}
>
<div className="flex h-full w-[var(--fd-toc-width)] max-w-full flex-col gap-3 pe-2">
<div className="flex h-full w-[var(--fd-toc-width)] max-w-full flex-col gap-3 pe-4">
{props.children}
</div>
</div>
Expand Down

0 comments on commit cc80f5b

Please sign in to comment.