Skip to content

Commit 0155489

Browse files
committedMar 25, 2025
Docs: rewrite navigation guide
1 parent c63ba09 commit 0155489

File tree

11 files changed

+176
-192
lines changed

11 files changed

+176
-192
lines changed
 

‎apps/docs/content/docs/headless/page-conventions.mdx

+19-24
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ description: A shared convention for organizing your documents
55

66
## Overview
77

8-
On Fumadocs MDX, or other file-system based content sources, the sidebar items (page tree) are generated from your file structure.
9-
This is similar to Next.js's file system based routing.
8+
Page slugs and sidebar items (page tree) are generated from your file structure, similar to file-system based routing in Next.js.
9+
10+
> This only applies for file-system based content sources, such as Fumadocs MDX.
1011
1112
## File
1213

@@ -68,11 +69,11 @@ To create a folder group, wrap the folder name in parentheses.
6869

6970
## Meta
7071

71-
Customize a folder by creating a `meta.json` file in the folder.
72+
Customize a folder by creating a `meta.json` file in a folder under content folder.
7273

7374
### Display Name
7475

75-
```json
76+
```json title="meta.json"
7677
{
7778
"title": "Name of Folder"
7879
}
@@ -95,7 +96,7 @@ Control the order of items.
9596

9697
When a meta file is present, items are not included unless you have explicitly added them to `pages`.
9798

98-
```json
99+
```json title="meta.json"
99100
{
100101
"title": "Name of Folder",
101102
"pages": ["guide", "components"]
@@ -112,7 +113,7 @@ When a meta file is present, items are not included unless you have explicitly a
112113

113114
The items of `pages` can also be a relative path to a page or folder, no file extensions needed.
114115

115-
```json
116+
```json title="meta.json"
116117
{
117118
"title": "Name of Folder",
118119
"pages": ["../headless/page"]
@@ -134,7 +135,7 @@ Force to open the folder by default.
134135

135136
You can define a separator in meta by adding a item surrounded with `---`.
136137

137-
```json
138+
```json title="meta.json"
138139
{
139140
"title": "Name of Folder",
140141
"pages": ["---Separator---"]
@@ -149,7 +150,7 @@ Add a Rest (`...`) item to automatically add and sort remaining page items alpha
149150
Index pages won't be included, you must specify the order of `index`.
150151
</Callout>
151152

152-
```json
153+
```json title="meta.json"
153154
{
154155
"title": "Folder",
155156
"pages": ["guide", "..."]
@@ -158,7 +159,7 @@ Add a Rest (`...`) item to automatically add and sort remaining page items alpha
158159

159160
You can also sort items reversely.
160161

161-
```json
162+
```json title="meta.json"
162163
{
163164
"title": "Folder",
164165
"pages": ["guide", "z...a"]
@@ -169,7 +170,7 @@ You can also sort items reversely.
169170

170171
In conjunction with the Rest item (`...`), you can use `!name` to exclude an item from the rest.
171172

172-
```json
173+
```json title="meta.json"
173174
{
174175
"title": "Folder",
175176
"pages": ["...", "!hide-this-page"]
@@ -180,7 +181,7 @@ In conjunction with the Rest item (`...`), you can use `!name` to exclude an ite
180181

181182
You can extract the items from a folder with `...folder_name`.
182183

183-
```json
184+
```json title="meta.json"
184185
{
185186
"title": "Folder",
186187
"pages": ["guide", "...folder"]
@@ -191,7 +192,7 @@ You can extract the items from a folder with `...folder_name`.
191192

192193
Use the syntax `[Text](url)` to insert links.
193194

194-
```json
195+
```json title="meta.json"
195196
{
196197
"title": "Folder",
197198
"pages": ["index", "[Vercel](https://vercel.com)"]
@@ -200,7 +201,7 @@ Use the syntax `[Text](url)` to insert links.
200201

201202
You can add an icon too.
202203

203-
```json
204+
```json title="meta.json"
204205
{
205206
"title": "Folder",
206207
"pages": ["index", "[Triangle][Vercel](https://vercel.com)"]
@@ -215,13 +216,13 @@ You can add an [`icon` handler](/docs/headless/source-api#icons) to `loader()`.
215216

216217
## Root Folder
217218

218-
<div className='max-w-[360px] mx-auto'>
219+
Marks the folder as a root folder.
219220

220-
![Sidebar Tabs](/docs/sidebar-tabs.png)
221+
<Callout title='Fumadocs UI'>
221222

222-
</div>
223+
Fumadocs UI renders root folders as [Sidebar Tabs](/docs/ui/navigation/sidebar#sidebar-tabs), which allows user to switch between them.
223224

224-
Adding a `root` property in meta file can mark your folder as a **root**.
225+
</Callout>
225226

226227
```json title="meta.json"
227228
{
@@ -231,7 +232,7 @@ Adding a `root` property in meta file can mark your folder as a **root**.
231232
}
232233
```
233234

234-
When the user is browsing a page under a root folder, only the child items of the folder will be visible.
235+
Only items in the current root folder will be considered.
235236

236237
For example, when you are in a root folder called `framework`, the other folders (e.g. `headless`) are not shown on the sidebar and other navigation elements.
237238

@@ -245,13 +246,7 @@ For example, when you are in a root folder called `framework`, the other folders
245246
</Folder>
246247
</Files>
247248

248-
<Callout title='Fumadocs UI'>
249-
250-
Fumadocs UI renders root folders as Sidebar Tabs, which allows user to switch between them.
251249

252-
You can customise it via [`sidebar.tabs`](/docs/ui/layouts/docs#sidebar-tabs) in Docs Layout.
253-
254-
</Callout>
255250

256251
### Index Pages
257252

‎apps/docs/content/docs/ui/index.mdx

+31-21
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ A command line tool to install UI components and automate things, useful for cus
4747

4848
**Markdown/MDX:** Markdown is a markup language for creating formatted text. Fumadocs supports Markdown and MDX (superset of Markdown) out-of-the-box.
4949

50-
Some basic knowledge of Next.js App Router would be useful for further customisations.
50+
Although not required, some basic knowledge of Next.js App Router would be useful for further customisations.
5151

5252
## Automatic Installation
5353

54-
Create a new app with `create-fumadocs-app`.
54+
A minimum version of Node.js 18 required, note that Node.js 23.1 might have problems with Next.js production build.
5555

5656
<Tabs groupId='package-manager' persist items={['npm', 'pnpm', 'yarn', 'bun']}>
5757

@@ -73,10 +73,7 @@ bun create fumadocs-app
7373

7474
</Tabs>
7575

76-
> Node.js 18 or above required, Node.js 23.1 might have problems with Next.js production build.
77-
78-
It will initialize a new fumadocs app.
79-
Now you can start hacking!
76+
It will initialize a new fumadocs app. Now you can start hacking!
8077

8178
<Callout title='From Existing Codebase?'>
8279

@@ -115,39 +112,41 @@ In the project, you can see:
115112
| `app/docs` | The documentation layout and pages. |
116113
| `app/api/search/route.ts` | The Route Handler for search. |
117114

118-
### Customise Content
115+
### Writing Content
116+
117+
For authoring docs, make sure to read:
118+
119+
<Cards>
120+
<Card href="/docs/ui/markdown" title="Markdown">
121+
Fumadocs has some additional features for authoring content too.
122+
</Card>
123+
<Card href="/docs/ui/navigation" title="Navigation">
124+
Learn how to customise navigation links/sidebar items.
125+
</Card>
126+
</Cards>
127+
128+
### Content Source
119129

120130
Content source handles all your content, like compiling Markdown files and validating frontmatter.
121131

122132
<Tabs items={['Fumadocs MDX', 'Custom Source']}>
123133

124134
<Tab value='Fumadocs MDX'>
125135

126-
Read the [Introduction](/docs/mdx) to learn how it handles your content.
136+
Read the [Introduction](/docs/mdx) to learn how it handles your content.
127137

128-
A `source.config.ts` config file has been included, you can customise different options like frontmatter schema.
138+
A `source.config.ts` config file has been included, you can customise different options like frontmatter schema.
129139

130140
</Tab>
131141

132142
<Tab value='Custom Source'>
133143

134-
Fumadocs is not Markdown-exclusive. For other sources like Sanity, you can build a [custom content source](/docs/headless/custom-source).
144+
Fumadocs is not Markdown-exclusive. For other sources like Sanity, you can build a [custom content source](/docs/headless/custom-source).
135145

136146
</Tab>
137147

138148
</Tabs>
139149

140-
### Writing Content
141-
142-
<Cards>
143-
<Card href="/docs/ui/markdown" title="Markdown">
144-
Fumadocs has some additional features for authoring content too.
145-
</Card>
146-
<Card href="/docs/ui/page-conventions" title="Organizing Pages">
147-
Learn how to organize your content.
148-
</Card>
149-
</Cards>
150-
151150
### Customise UI
152151

153152
See [Customisation Guide](/docs/ui/customisation).
@@ -232,6 +231,17 @@ will replace the `/docs` page with your `page.tsx`.
232231

233232
</Accordion>
234233

234+
<Accordion id='multi-versions' title="How to implement docs with multi-version?">
235+
Use a separate deployment for each version.
236+
237+
On Vercel, this can be done by creating another branch for a specific version on your GitHub repository.
238+
To link to the sites of other versions, use the Links API or a custom navigation component.
239+
</Accordion>
240+
241+
<Accordion id='multi-docs' title="How to implement multi-docs?">
242+
We recommend to use [Sidebar Tabs](/docs/ui/navigation/sidebar#sidebar-tabs).
243+
</Accordion>
244+
235245
</Accordions>
236246

237247
## Learn More

‎apps/docs/content/docs/ui/layouts/docs.mdx

+46-33
Original file line numberDiff line numberDiff line change
@@ -45,62 +45,75 @@ import { DocsLayout } from 'fumadocs-ui/layouts/docs';
4545

4646
<AutoTypeTable path="./content/docs/ui/props.ts" name="SidebarProps" />
4747

48-
## Sidebar Tabs
48+
### Sidebar Tabs
4949

50-
A navigation component to switch between root folders.
50+
See [Navigation Guide](/docs/ui/navigation/sidebar#sidebar-tabs) for usages.
5151

52-
<div className='max-w-[360px] mx-auto'>
52+
#### Decoration
5353

54-
![Sidebar Tabs](/docs/sidebar-tabs.png)
55-
56-
</div>
57-
58-
You can add items from the page tree (see [Root Folder](/docs/ui/page-conventions#root-folder)), or specify them explicitly:
54+
Change the icon/styles of tabs.
5955

6056
```tsx
6157
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
6258

6359
<DocsLayout
6460
sidebar={{
65-
tabs: [
66-
{
67-
title: 'Test',
68-
description: 'Test Tab',
69-
url: '/docs/test',
70-
},
71-
],
61+
tabs: {
62+
transform: (option, node) => ({
63+
...option,
64+
icon: 'my icon',
65+
}),
66+
},
7267
}}
7368
/>;
7469
```
7570

76-
Set it to `false` to disable:
71+
## Nav
7772

78-
```tsx
79-
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
73+
A mobile-only navbar, we recommend to customise it from `baseOptions`.
74+
75+
<div className='max-w-[460px] mx-auto'>
8076

81-
<DocsLayout sidebar={{ tabs: false }} />;
77+
![Docs Nav](/docs/docs-nav.png)
78+
79+
</div>
80+
81+
```tsx
82+
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
83+
84+
export const baseOptions: BaseLayoutProps = {
85+
githubUrl: 'https://github.com/fuma-nama/fumadocs',
86+
nav: {
87+
title: 'My App',
88+
},
89+
};
8290
```
8391

84-
### Decoration
92+
<AutoTypeTable
93+
path="./content/docs/ui/props.ts"
94+
type="Omit<NavbarProps, 'children'>"
95+
/>
8596

86-
Change the icon/styles of tabs.
97+
### Transparent Mode
98+
99+
To make the navbar background transparent, you can configure transparent mode.
87100

88101
```tsx
89-
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
102+
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
90103

91-
<DocsLayout
92-
sidebar={{
93-
tabs: {
94-
transform: (option, node) => ({
95-
...option,
96-
icon: 'my icon',
97-
}),
98-
},
99-
}}
100-
/>;
104+
export const baseOptions: BaseLayoutProps = {
105+
nav: {
106+
transparentMode: 'top',
107+
},
108+
};
101109
```
102110

103-
<include cwd>./content/shared/shared.nav.mdx</include>
111+
| Mode | Description |
112+
| -------- | ----------------------------------- |
113+
| `always` | Always use a transparent background |
114+
| `top` | When at the top of page |
115+
| `none` | Disable transparent background (default) |
116+
104117

105118
### Replace Navbar
106119

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Navigation
3+
description: Configure navigation in your Fumadocs app.
4+
index: true
5+
---

0 commit comments

Comments
 (0)
Failed to load comments.