@vercel/geistdocs 1.12.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -0
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +7 -5
- package/dist/footer.d.ts +1 -1
- package/dist/footer.d.ts.map +1 -1
- package/dist/footer.js +1 -1
- package/dist/home-layout.d.ts.map +1 -1
- package/dist/home-layout.js +2 -7
- package/dist/internal/chat/shell.d.ts.map +1 -1
- package/dist/internal/chat/shell.js +2 -1
- package/dist/internal/footer/rss-button.d.ts +3 -1
- package/dist/internal/footer/rss-button.d.ts.map +1 -1
- package/dist/internal/footer/rss-button.js +2 -1
- package/dist/internal/localized-link.d.ts.map +1 -1
- package/dist/internal/localized-link.js +9 -4
- package/dist/internal/page-actions-client.d.ts +1 -0
- package/dist/internal/page-actions-client.d.ts.map +1 -1
- package/dist/internal/page-actions-client.js +2 -4
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +1 -1
- package/dist/internal/search.d.ts.map +1 -1
- package/dist/internal/search.js +2 -1
- package/dist/internal/sidebar-responsive.d.ts +3 -0
- package/dist/internal/sidebar-responsive.d.ts.map +1 -0
- package/dist/internal/sidebar-responsive.js +10 -0
- package/dist/internal/sidebar-tree.d.ts +23 -0
- package/dist/internal/sidebar-tree.d.ts.map +1 -0
- package/dist/internal/sidebar-tree.js +115 -0
- package/dist/internal/sidebar.d.ts +2 -5
- package/dist/internal/sidebar.d.ts.map +1 -1
- package/dist/internal/sidebar.js +282 -44
- package/dist/internal/table-of-contents.js +1 -1
- package/dist/internal/ui/sheet.d.ts.map +1 -1
- package/dist/internal/ui/sheet.js +2 -2
- package/dist/internal/version-paths.d.ts +49 -0
- package/dist/internal/version-paths.d.ts.map +1 -0
- package/dist/internal/version-paths.js +57 -0
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +1 -6
- package/dist/mdx.d.ts +1 -0
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mobile-docs-bar.d.ts.map +1 -1
- package/dist/mobile-docs-bar.js +3 -3
- package/dist/navbar.js +1 -1
- package/dist/pages/docs.d.ts +25 -7
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +40 -8
- package/dist/proxy.d.ts +4 -3
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +124 -46
- package/dist/routes/agents.d.ts +1 -1
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +27 -16
- package/dist/routes/chat.d.ts +1 -1
- package/dist/routes/chat.d.ts.map +1 -1
- package/dist/routes/chat.js +18 -11
- package/dist/routes/discovery.d.ts +6 -2
- package/dist/routes/discovery.d.ts.map +1 -1
- package/dist/routes/discovery.js +6 -12
- package/dist/routes/sitemap.d.ts +3 -2
- package/dist/routes/sitemap.d.ts.map +1 -1
- package/dist/routes/sitemap.js +18 -5
- package/dist/source-config.d.ts +1 -0
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +1 -0
- package/dist/source.d.ts +40 -2
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +132 -15
- package/dist/versions.d.ts +22 -2
- package/dist/versions.d.ts.map +1 -1
- package/dist/versions.js +29 -6
- package/docs/agents.md +2 -2
- package/docs/llms.txt +313 -31
- package/docs/manifest.json +10 -9
- package/docs/pages/configuration.md +26 -1
- package/docs/pages/getting-started.md +2 -0
- package/docs/pages/guides/nested-navigation.md +174 -13
- package/docs/pages/md.md +4 -0
- package/docs/pages/migration.md +4 -0
- package/docs/pages/proxy.md +15 -0
- package/docs/pages/rss.md +2 -0
- package/docs/pages/syntax.md +2 -1
- package/docs/pages/versioned-docs.md +68 -0
- package/docs/sitemap.md +1 -1
- package/package.json +1 -1
- package/source-config.js +1 -0
- package/template/AGENTS.md +2 -0
- package/template/app/[lang]/rss.xml/route.ts +7 -3
- package/template/app/styles/geistdocs.css +8 -6
- package/template/content/docs/configuration.mdx +26 -1
- package/template/content/docs/getting-started.mdx +2 -0
- package/template/content/docs/guides/nested-navigation.mdx +174 -12
- package/template/content/docs/md.mdx +4 -0
- package/template/content/docs/migration.mdx +4 -0
- package/template/content/docs/proxy.mdx +15 -0
- package/template/content/docs/rss.mdx +2 -0
- package/template/content/docs/syntax.mdx +2 -1
- package/template/content/docs/versioned-docs.mdx +68 -0
- package/template/package.json +1 -1
- package/theme.css +150 -0
|
@@ -1,23 +1,184 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
2
|
+
title: Configure sidebar navigation
|
|
3
|
+
description: Organize Geistdocs pages with ordered groups, separators, folder indexes, and nested navigation
|
|
4
4
|
type: guide
|
|
5
|
+
summary: Configure sidebar order, section labels, folder landing pages, and deeply nested page trees with meta.json files.
|
|
5
6
|
url: /docs/guides/nested-navigation
|
|
6
7
|
source: apps/template/content/docs/guides/nested-navigation.mdx
|
|
8
|
+
prerequisites:
|
|
9
|
+
- /docs/getting-started
|
|
10
|
+
related:
|
|
11
|
+
- /docs/configuration
|
|
12
|
+
- /docs/syntax
|
|
7
13
|
---
|
|
8
14
|
|
|
9
|
-
#
|
|
15
|
+
# Configure sidebar navigation
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
automatically from the page tree. This page lives under the **Guides** folder,
|
|
13
|
-
so the breadcrumb above reads _Guides_.
|
|
17
|
+
Use `meta.json` files to organize the Geistdocs sidebar without changing layout components. Each `meta.json` controls the pages and folders in its own directory, so the same pattern works at every nesting level.
|
|
14
18
|
|
|
15
|
-
##
|
|
19
|
+
## Start with the content tree
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
rendered on the server from the page's URL and the sidebar tree, so it is
|
|
19
|
-
present in the initial HTML — the page title never shifts once the page
|
|
20
|
-
hydrates.
|
|
21
|
+
Directories become sidebar folders, and `.mdx` files become pages. The examples on this page use the following content tree:
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
```text
|
|
24
|
+
content/docs/
|
|
25
|
+
├── index.mdx
|
|
26
|
+
├── getting-started.mdx
|
|
27
|
+
├── architecture.mdx
|
|
28
|
+
├── api-reference.mdx
|
|
29
|
+
├── changelog.mdx
|
|
30
|
+
├── meta.json
|
|
31
|
+
└── guides/
|
|
32
|
+
├── index.mdx
|
|
33
|
+
├── quickstarts.mdx
|
|
34
|
+
├── meta.json
|
|
35
|
+
└── integrations/
|
|
36
|
+
├── nextjs.mdx
|
|
37
|
+
├── sveltekit.mdx
|
|
38
|
+
├── meta.json
|
|
39
|
+
└── advanced/
|
|
40
|
+
├── index.mdx
|
|
41
|
+
├── caching.mdx
|
|
42
|
+
├── security.mdx
|
|
43
|
+
└── meta.json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Every page needs a frontmatter `title`. Add a `description` to summarize the page. For a regular page, the frontmatter title becomes its sidebar label. Folder landing pages use the folder behavior described below.
|
|
47
|
+
|
|
48
|
+
## Order top-level pages and add separators
|
|
49
|
+
|
|
50
|
+
Add page and folder names to the root `pages` array without file extensions:
|
|
51
|
+
|
|
52
|
+
```json title="content/docs/meta.json"
|
|
53
|
+
{
|
|
54
|
+
"title": "My Product Documentation",
|
|
55
|
+
"root": true,
|
|
56
|
+
"pages": [
|
|
57
|
+
"index",
|
|
58
|
+
"getting-started",
|
|
59
|
+
"---Guides---",
|
|
60
|
+
"guides",
|
|
61
|
+
"---Internals---",
|
|
62
|
+
"architecture",
|
|
63
|
+
"api-reference",
|
|
64
|
+
"---Resources---",
|
|
65
|
+
"..."
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This configuration produces three labeled groups after the two introductory pages:
|
|
71
|
+
|
|
72
|
+
- `---Guides---` adds a non-clickable **Guides** separator before the `guides` folder.
|
|
73
|
+
- `---Internals---` adds an **Internals** separator before the architecture and API reference pages.
|
|
74
|
+
- `---Resources---` adds a **Resources** separator before pages inserted by `...`.
|
|
75
|
+
|
|
76
|
+
The `...` entry inserts every page or folder that is not named elsewhere in the array. Place it where the remaining items should appear. Without `...`, unnamed items do not appear in that folder's sidebar navigation.
|
|
77
|
+
|
|
78
|
+
On desktop, top-level folders open as dedicated sidebar sections. On mobile, Geistdocs renders the same page tree as expandable nested navigation. Both layouts use the same `meta.json` files.
|
|
79
|
+
|
|
80
|
+
## Add a folder landing page
|
|
81
|
+
|
|
82
|
+
Create `index.mdx` inside a nested directory when the folder needs its own landing page:
|
|
83
|
+
|
|
84
|
+
```mdx title="content/docs/guides/index.mdx"
|
|
85
|
+
---
|
|
86
|
+
title: Guides
|
|
87
|
+
description: Follow task-focused guides for My Product.
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
Choose a guide based on the workflow you want to complete.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Then order the folder's child pages in its `meta.json`:
|
|
94
|
+
|
|
95
|
+
```json title="content/docs/guides/meta.json"
|
|
96
|
+
{
|
|
97
|
+
"title": "Guides",
|
|
98
|
+
"pages": ["quickstarts", "integrations"]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Leave `index` out of a nested folder's `pages` array to use `index.mdx` as the folder landing page. In the desktop section view, Geistdocs exposes a top-level folder index as **Overview**. For a nested folder, the folder label links to its index while the disclosure control expands its children.
|
|
103
|
+
|
|
104
|
+
If you include `index` explicitly in `pages`, Geistdocs treats it as a regular child page instead of the folder landing page.
|
|
105
|
+
|
|
106
|
+
## Configure deeply nested folders
|
|
107
|
+
|
|
108
|
+
Add another `meta.json` inside each nested directory. For the `integrations` folder from the example tree, group framework pages separately from advanced topics:
|
|
109
|
+
|
|
110
|
+
```json title="content/docs/guides/integrations/meta.json"
|
|
111
|
+
{
|
|
112
|
+
"title": "Integrations",
|
|
113
|
+
"defaultOpen": true,
|
|
114
|
+
"pages": [
|
|
115
|
+
"---Frameworks---",
|
|
116
|
+
"nextjs",
|
|
117
|
+
"sveltekit",
|
|
118
|
+
"---Advanced---",
|
|
119
|
+
"advanced"
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The `advanced` directory can define another level:
|
|
125
|
+
|
|
126
|
+
```json title="content/docs/guides/integrations/advanced/meta.json"
|
|
127
|
+
{
|
|
128
|
+
"title": "Advanced Integrations",
|
|
129
|
+
"pages": ["caching", "security"]
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Because `advanced/index.mdx` exists and is not listed in `pages`, **Advanced Integrations** links to `/docs/guides/integrations/advanced`. Its child pages resolve to:
|
|
134
|
+
|
|
135
|
+
- `/docs/guides/integrations/advanced/caching`
|
|
136
|
+
- `/docs/guides/integrations/advanced/security`
|
|
137
|
+
|
|
138
|
+
Set `defaultOpen` to `true` when a folder should start expanded. Geistdocs also opens the folders that contain the active page, unless a folder explicitly sets `defaultOpen` to `false`.
|
|
139
|
+
|
|
140
|
+
## Add a badge to a page
|
|
141
|
+
|
|
142
|
+
Add a short `badge` value to page frontmatter to show status or availability beside its sidebar label:
|
|
143
|
+
|
|
144
|
+
```yaml title="content/docs/guides/new-api.mdx"
|
|
145
|
+
---
|
|
146
|
+
title: New API
|
|
147
|
+
description: Use the new API in your application.
|
|
148
|
+
badge: Beta
|
|
149
|
+
---
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Geistdocs renders the badge in desktop and mobile navigation. Badges also appear on folder landing pages because their sidebar items use the folder's `index.mdx` frontmatter. Keep badge text short so the page label has enough room to remain readable.
|
|
153
|
+
|
|
154
|
+
## Add links to the navigation
|
|
155
|
+
|
|
156
|
+
The `pages` array can include internal and external links alongside content files:
|
|
157
|
+
|
|
158
|
+
```json title="content/docs/meta.json"
|
|
159
|
+
{
|
|
160
|
+
"pages": [
|
|
161
|
+
"index",
|
|
162
|
+
"[Status](/status)",
|
|
163
|
+
"external:[GitHub](https://github.com/my-org/my-repo)"
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Use `[Label](/path)` for an internal link. Prefix an external link with `external:` so Geistdocs opens it in a new tab and shows the external-link indicator.
|
|
169
|
+
|
|
170
|
+
## Check breadcrumbs for nested pages
|
|
171
|
+
|
|
172
|
+
Geistdocs builds breadcrumbs from the same page tree. A page at `content/docs/guides/integrations/advanced/caching.mdx` receives the folder path **Guides**, **Integrations**, and **Advanced Integrations** before its page title.
|
|
173
|
+
|
|
174
|
+
Breadcrumbs render on the server from the page URL and sidebar tree, so they are present in the initial HTML. Top-level pages have no folder ancestors and do not render a breadcrumb.
|
|
175
|
+
|
|
176
|
+
## Troubleshoot missing navigation items
|
|
177
|
+
|
|
178
|
+
Check these rules when a page or folder does not appear where expected:
|
|
179
|
+
|
|
180
|
+
- Match each `pages` entry to a file or directory name without its extension.
|
|
181
|
+
- Add a `meta.json` to every folder that needs custom ordering, separators, `defaultOpen` behavior, or a title override.
|
|
182
|
+
- Add `...` when unlisted files and folders should remain visible.
|
|
183
|
+
- Leave `index` out of a nested folder's `pages` array when it should act as the folder landing page.
|
|
184
|
+
- Keep separator labels between three hyphens on each side, such as `---Internals---`.
|
package/docs/pages/md.md
CHANGED
|
@@ -37,6 +37,10 @@ The `.mdx` version returns:
|
|
|
37
37
|
- The full processed Markdown content
|
|
38
38
|
- No HTML, styling, or navigation
|
|
39
39
|
|
|
40
|
+
For a docs section mounted at `/docs`, the section root remains `/docs.md`. For a source mounted at the app root with `baseUrl: "/"`, Geistdocs uses `/index.md` for the root page. If Next.js has `basePath: "/docs"`, that public root Markdown URL is `/docs/index.md`.
|
|
41
|
+
|
|
42
|
+
Copy Page, View as Markdown, and the `text/markdown` metadata alternate all use the same package resolver. Use `createDocsPage({ getMarkdownUrl })` only when the deployment needs a different public contract.
|
|
43
|
+
|
|
40
44
|
## Use cases
|
|
41
45
|
|
|
42
46
|
This feature is particularly useful for:
|
package/docs/pages/migration.md
CHANGED
|
@@ -147,6 +147,8 @@ export const geistdocsSource = createSource({
|
|
|
147
147
|
});
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
+
If the Next.js application also uses `basePath`, pass the same value through `defineConfig` but do not add it to `baseUrl`, `content.route`, `getPageUrl`, or `markdownRoutes`. Those values remain app-local. Geistdocs adds the public prefix to page actions, metadata, generated Markdown, discovery links, chat citations, and proxy destinations.
|
|
151
|
+
|
|
150
152
|
## Add route adapters
|
|
151
153
|
|
|
152
154
|
Keep App Router files thin. Route files should call package helpers instead of copying package internals.
|
|
@@ -321,6 +323,8 @@ const proxy = createProxy({
|
|
|
321
323
|
});
|
|
322
324
|
```
|
|
323
325
|
|
|
326
|
+
For a base-path application whose root page is documentation, add `"/"` to the static proxy matcher and verify `<basePath>/index.md`. Keep normal application and API paths out of a broad root Markdown mapping with matcher exclusions or a `before` hook.
|
|
327
|
+
|
|
324
328
|
## Configure Tailwind CSS
|
|
325
329
|
|
|
326
330
|
Tailwind CSS v4 requires `@source` entries for package components and related dependencies.
|
package/docs/pages/proxy.md
CHANGED
|
@@ -121,6 +121,8 @@ With these mappings:
|
|
|
121
121
|
|
|
122
122
|
Use `[lang]` in the destination when your markdown route is nested under `app/[lang]`. Use `*path` or `:path*` to insert the matched wildcard path.
|
|
123
123
|
|
|
124
|
+
`markdownRoutes` are app-local even when `config.basePath` is set. For a Next.js `basePath` of `/docs`, keep a mapping such as `{ from: "/*path", to: "/[lang]/llms.mdx/*path" }`. `createProxy` preserves `/docs` when it rewrites the public request.
|
|
125
|
+
|
|
124
126
|
## Root-mounted docs
|
|
125
127
|
|
|
126
128
|
For docs served from the site root, set the source `baseUrl` and config route to `/`:
|
|
@@ -162,6 +164,19 @@ const proxy = createProxy({
|
|
|
162
164
|
});
|
|
163
165
|
```
|
|
164
166
|
|
|
167
|
+
When root-mounted docs are the entire base-path application, include `"/"` explicitly in the static matcher. Next.js does not apply a catch-all matcher to the base-path root:
|
|
168
|
+
|
|
169
|
+
```ts title="proxy.ts"
|
|
170
|
+
export const config = {
|
|
171
|
+
matcher: [
|
|
172
|
+
"/",
|
|
173
|
+
"/((?!api(?:/|$)|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
|
|
174
|
+
],
|
|
175
|
+
};
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The package keeps `llms.txt`, `sitemap.md`, `agents.md`, MCP discovery, and RSS out of root page-Markdown negotiation. Continue to exclude site-specific application and API routes with the matcher or a `before` hook. A root Markdown page is exposed as `/index.md`, or `<basePath>/index.md` publicly.
|
|
179
|
+
|
|
165
180
|
## Hook context
|
|
166
181
|
|
|
167
182
|
Both `before` and `after` receive the same context:
|
package/docs/pages/rss.md
CHANGED
|
@@ -47,6 +47,8 @@ Users can subscribe to this URL using:
|
|
|
47
47
|
|
|
48
48
|
An RSS button appears in the navigation bar so readers can discover and subscribe to your feed. Clicking the button opens the RSS XML in a new tab.
|
|
49
49
|
|
|
50
|
+
The package Footer applies `config.basePath` to this link. Custom RSS generators must also apply the base path to channel and item URLs; source `page.url` values intentionally remain app-local for Next.js navigation.
|
|
51
|
+
|
|
50
52
|
## Feed Format
|
|
51
53
|
|
|
52
54
|
The RSS feed follows the RSS 2.0 specification and includes:
|
package/docs/pages/syntax.md
CHANGED
|
@@ -25,10 +25,11 @@ Every MDX file should include frontmatter at the top:
|
|
|
25
25
|
---
|
|
26
26
|
title: Page Title
|
|
27
27
|
description: A brief description of the page content
|
|
28
|
+
badge: Beta
|
|
28
29
|
---
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
The `title` property is required and is used for the page heading and navigation. The `description` is used for SEO and page previews.
|
|
32
|
+
The `title` property is required and is used for the page heading and navigation. The `description` is used for SEO and page previews. The optional `badge` appears beside the page label in desktop and mobile sidebar navigation.
|
|
32
33
|
|
|
33
34
|
## Basic Markdown
|
|
34
35
|
|
|
@@ -220,6 +220,74 @@ For host-based versions, use `href` instead of `routePrefix`:
|
|
|
220
220
|
/>
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
+
## Avoid 404s when switching versions
|
|
224
|
+
|
|
225
|
+
By default the selector swaps the route prefix without checking that the page
|
|
226
|
+
exists in the target version, so pages that exist in only one version 404 on
|
|
227
|
+
switch. Pass `paths` — computed server-side with `collectVersionSwitchPaths` —
|
|
228
|
+
and the selector falls back to the nearest existing ancestor (or the version's
|
|
229
|
+
docs root) instead:
|
|
230
|
+
|
|
231
|
+
```tsx title="app/[lang]/docs/layout.tsx"
|
|
232
|
+
import { collectVersionSwitchPaths } from "@vercel/geistdocs/source";
|
|
233
|
+
import { GeistdocsVersionSelect } from "@vercel/geistdocs/versions";
|
|
234
|
+
import { config } from "@/lib/geistdocs/config";
|
|
235
|
+
import { versions } from "@/lib/geistdocs/source";
|
|
236
|
+
|
|
237
|
+
const DocsLayout = async ({ children, params }) => {
|
|
238
|
+
const { lang } = await params;
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<GeistdocsDocsLayout
|
|
242
|
+
config={config}
|
|
243
|
+
sidebarTop={
|
|
244
|
+
<GeistdocsVersionSelect
|
|
245
|
+
current={versions.currentVersion}
|
|
246
|
+
paths={collectVersionSwitchPaths({ lang, versions })}
|
|
247
|
+
versions={config.versions}
|
|
248
|
+
/>
|
|
249
|
+
}
|
|
250
|
+
tree={versions.current.source.pageTree[lang]}
|
|
251
|
+
>
|
|
252
|
+
{children}
|
|
253
|
+
</GeistdocsDocsLayout>
|
|
254
|
+
);
|
|
255
|
+
};
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`collectVersionSwitchPaths` enumerates every page of every version from the
|
|
259
|
+
`createVersionedSources` output and returns paths relative to each version's
|
|
260
|
+
`routePrefix`, plus each version's docs root as the fallback landing page.
|
|
261
|
+
|
|
262
|
+
When an app rewrites loader URLs at render time (for example serving a
|
|
263
|
+
`baseUrl: "/docs"` source under `/v5` with a custom `getPageUrl`), pass the
|
|
264
|
+
same mapping so the collected paths match the public URLs. For sources that
|
|
265
|
+
span several loaders per version (for example separate docs and cookbook
|
|
266
|
+
sources), use the lower-level `collectVersionPaths` per version instead:
|
|
267
|
+
|
|
268
|
+
```tsx
|
|
269
|
+
import { collectVersionPaths } from "@vercel/geistdocs/source";
|
|
270
|
+
|
|
271
|
+
const paths = {
|
|
272
|
+
v4: {
|
|
273
|
+
fallbackPath: "/docs",
|
|
274
|
+
paths: collectVersionPaths({ lang, sources: [v4Docs, v4Cookbook] }),
|
|
275
|
+
},
|
|
276
|
+
v5: {
|
|
277
|
+
fallbackPath: "/docs",
|
|
278
|
+
paths: collectVersionPaths({
|
|
279
|
+
lang,
|
|
280
|
+
routePrefix: "/v5",
|
|
281
|
+
sources: [v5Docs, v5Cookbook],
|
|
282
|
+
}),
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Fallback resolution only applies to `routePrefix` versions. Host-based
|
|
288
|
+
versions (`href`) always keep the plain path swap, since the target host's
|
|
289
|
+
pages can't be enumerated locally.
|
|
290
|
+
|
|
223
291
|
## Configure markdown routes
|
|
224
292
|
|
|
225
293
|
Each public route family needs a matching markdown route in `proxy.ts`. Read [Proxy and markdown routes](/docs/proxy) for the proxy configuration.
|
package/docs/sitemap.md
CHANGED
|
@@ -16,11 +16,11 @@ Use it to choose focused page files from `docs/pages/` before reading the full `
|
|
|
16
16
|
- [.md Extension](pages/md.md) | URL: /docs/md | Type: conceptual | Summary: Access any documentation page as raw Markdown by appending .md or .mdx to the URL for AI tool consumption.
|
|
17
17
|
- [Agent readiness](pages/agent-readiness.md) | URL: /docs/agent-readiness | Type: guide | Summary: Generate /agents.md and /.well-known/mcp.json from Geistdocs config so agents can find docs, Markdown surfaces, API specs, and MCP endpoints.
|
|
18
18
|
- [Ask AI](pages/ask-ai.md) | URL: /docs/ask-ai | Type: conceptual | Summary: An AI-powered chat assistant with context-aware search, persistent history, and suggested prompts for your documentation.
|
|
19
|
+
- [Configure sidebar navigation](pages/guides/nested-navigation.md) | URL: /docs/guides/nested-navigation | Type: guide | Summary: Configure sidebar order, section labels, folder landing pages, and deeply nested page trees with meta.json files.
|
|
19
20
|
- [Edit on GitHub](pages/edit-on-github.md) | URL: /docs/edit-on-github | Type: integration | Summary: A direct link on every documentation page that lets readers propose changes through GitHub pull requests.
|
|
20
21
|
- [Feedback](pages/feedback.md) | URL: /docs/feedback | Type: integration | Summary: An interactive feedback widget that collects user sentiment and creates structured GitHub Issues automatically.
|
|
21
22
|
- [Internationalization](pages/internationalization.md) | URL: /docs/internationalization | Type: guide | Summary: Serve documentation in multiple languages with automatic translation via the Geistdocs CLI and Fumadocs routing.
|
|
22
23
|
- [llms.txt](pages/llms-txt.md) | URL: /docs/llms-txt | Type: conceptual | Summary: A single endpoint that returns all documentation as plain Markdown text following the llms.txt standard.
|
|
23
|
-
- [Nested navigation](pages/guides/nested-navigation.md) | URL: /docs/guides/nested-navigation | Type: guide
|
|
24
24
|
- [Open in Chat](pages/open-in-chat.md) | URL: /docs/open-in-chat | Type: conceptual | Summary: Transfer documentation context to AI chat platforms like ChatGPT, Claude, Cursor, and v0 with a single click.
|
|
25
25
|
- [RSS](pages/rss.md) | URL: /docs/rss | Type: conceptual | Summary: An automatically generated RSS 2.0 feed that keeps users informed when documentation is published or updated.
|
|
26
26
|
- [Theme-Aware Image](pages/theme-aware-image.md) | URL: /docs/theme-aware-image | Type: reference | Summary: A component that swaps images based on the active theme, built on top of Next.js Image.
|
package/package.json
CHANGED
package/source-config.js
CHANGED
package/template/AGENTS.md
CHANGED
|
@@ -56,6 +56,8 @@ Use these instructions when an AI coding agent edits this project.
|
|
|
56
56
|
- Preserve markdown negotiation unless the task explicitly changes AI-readable output. Geistdocs serves `/agents.md`, `/llms.txt`, `/.well-known/mcp.json`, and per-page Markdown for `.md`, `.mdx`, `Accept: text/markdown`, and AI-agent requests.
|
|
57
57
|
- When adding custom proxy behavior, prefer `before`, `after`, and `markdownRoutes` options on `createProxy` instead of replacing the proxy.
|
|
58
58
|
- Use explicit `markdownRoutes` for root-mounted docs or any site where homepage/app routes coexist with docs routes.
|
|
59
|
+
- Keep source URLs, navigation links, `getPageUrl`, and `markdownRoutes` app-local when `config.basePath` is set. Geistdocs derives public page-action and Markdown URLs separately.
|
|
60
|
+
- Include `"/"` explicitly in the static proxy matcher when a Next.js base-path application serves documentation at its app root.
|
|
59
61
|
|
|
60
62
|
## Ask AI and Vertex proxy guidelines
|
|
61
63
|
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { getPublicPath } from "@vercel/geistdocs/config";
|
|
1
2
|
import { Feed } from "feed";
|
|
2
3
|
import type { NextRequest } from "next/server";
|
|
3
4
|
import { title } from "@/geistdocs";
|
|
5
|
+
import { config } from "@/lib/geistdocs/config";
|
|
4
6
|
import { source } from "@/lib/geistdocs/source";
|
|
5
7
|
|
|
6
8
|
const protocol = process.env.NODE_ENV === "production" ? "https" : "http";
|
|
7
9
|
const baseUrl = `${protocol}://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`;
|
|
10
|
+
const sitePath = getPublicPath("/", config.basePath);
|
|
11
|
+
const siteUrl = sitePath === "/" ? baseUrl : `${baseUrl}${sitePath}`;
|
|
8
12
|
|
|
9
13
|
export const revalidate = false;
|
|
10
14
|
|
|
@@ -15,8 +19,8 @@ export const GET = async (
|
|
|
15
19
|
const { lang } = await params;
|
|
16
20
|
const feed = new Feed({
|
|
17
21
|
title,
|
|
18
|
-
id:
|
|
19
|
-
link:
|
|
22
|
+
id: siteUrl,
|
|
23
|
+
link: siteUrl,
|
|
20
24
|
language: lang,
|
|
21
25
|
copyright: `All rights reserved ${new Date().getFullYear()}, Vercel`,
|
|
22
26
|
});
|
|
@@ -32,7 +36,7 @@ export const GET = async (
|
|
|
32
36
|
id: page.url,
|
|
33
37
|
title: data.title ?? page.url,
|
|
34
38
|
description: data.description,
|
|
35
|
-
link: `${baseUrl}${page.url}`,
|
|
39
|
+
link: `${baseUrl}${getPublicPath(page.url, config.basePath)}`,
|
|
36
40
|
date: new Date(data.lastModified ?? new Date()),
|
|
37
41
|
author: [
|
|
38
42
|
{
|
|
@@ -17,18 +17,20 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/* Align docs content with navbar on mobile */
|
|
20
|
-
#nd-page {
|
|
21
|
-
@apply max-md:px-6;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
20
|
/*
|
|
25
21
|
* On mobile the sticky MobileDocsBar abuts the navbar via a negative top
|
|
26
22
|
* margin, which would otherwise overlap and clip the page breadcrumb rendered
|
|
27
23
|
* above it. Hide the breadcrumb on mobile so the bar sits flush under the
|
|
28
24
|
* navbar; it stays visible on desktop, where the bar is hidden.
|
|
29
25
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
@container (max-width: 960px) {
|
|
27
|
+
#nd-page {
|
|
28
|
+
@apply px-6;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#nd-page > .text-fd-muted-foreground:first-child {
|
|
32
|
+
@apply hidden;
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
/* TOC and footer links use gray-1000 */
|
|
@@ -9,6 +9,7 @@ related:
|
|
|
9
9
|
- /docs/migration
|
|
10
10
|
- /docs/provider
|
|
11
11
|
- /docs/env
|
|
12
|
+
- /docs/guides/nested-navigation
|
|
12
13
|
- /docs/versioned-docs
|
|
13
14
|
- /docs/proxy
|
|
14
15
|
---
|
|
@@ -38,6 +39,8 @@ Configure Geistdocs through user-owned files in the generated project. Runtime f
|
|
|
38
39
|
| `proxy.ts` | Configures markdown negotiation, AI-agent rewrites, request tracking, and custom request hooks. |
|
|
39
40
|
| `content/docs/meta.json` | Controls sidebar order and section labels. |
|
|
40
41
|
|
|
42
|
+
Read [Configure sidebar navigation](/docs/guides/nested-navigation) for page ordering, titled separators, folder indexes, nested folders, and custom navigation links.
|
|
43
|
+
|
|
41
44
|
## `geistdocs.tsx`
|
|
42
45
|
|
|
43
46
|
The root `geistdocs.tsx` file is the primary configuration surface:
|
|
@@ -174,6 +177,24 @@ export default defineGeistdocsSourceConfig();
|
|
|
174
177
|
|
|
175
178
|
To serve docs from the site root, use `route: "/"` in `content` and `baseUrl: "/"` in `createSource`. Root-mounted docs need explicit `markdownRoutes`; Geistdocs does not infer a broad `/*path` mapping because it can capture homepages and non-docs app routes.
|
|
176
179
|
|
|
180
|
+
## Next.js base paths
|
|
181
|
+
|
|
182
|
+
When Next.js mounts the application below a path, set the same value in `next.config.ts` and Geistdocs config:
|
|
183
|
+
|
|
184
|
+
```ts title="next.config.ts"
|
|
185
|
+
const config: NextConfig = {
|
|
186
|
+
basePath: "/docs",
|
|
187
|
+
};
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
```tsx title="geistdocs.tsx"
|
|
191
|
+
export const basePath = "/docs";
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Keep `content.route`, source `baseUrl`, navigation links, `getPageUrl`, search results, and proxy `markdownRoutes` app-local. Next.js applies the mount prefix to navigation. Geistdocs applies `basePath` separately to public page actions, Markdown metadata, generated Markdown and sitemap links, Ask AI citations, RSS discovery, and proxy rewrites.
|
|
195
|
+
|
|
196
|
+
For example, a root-mounted source with `baseUrl: "/"` still uses `page.url === "/guide"`. The public page is `/docs/guide`, and its Markdown URL is `/docs/guide.md`. The root page uses `/docs/index.md`.
|
|
197
|
+
|
|
177
198
|
## Page actions
|
|
178
199
|
|
|
179
200
|
Content actions appear in the **Copy page** menu beside the page title. **Scroll to top** and **Give feedback** remain below the table of contents so they stay available while you read. These actions are enabled by default and can be disabled through `defineConfig` in `lib/geistdocs/config.tsx`:
|
|
@@ -267,7 +288,11 @@ const docsPage = createDocsPage({
|
|
|
267
288
|
});
|
|
268
289
|
```
|
|
269
290
|
|
|
270
|
-
Use `getPageUrl` when the
|
|
291
|
+
Use `getPageUrl` when the app-local route differs from the source URL, such as `/v5/docs`. Geistdocs keeps that value app-local for previous and next navigation, then derives the public action URL with `config.basePath`.
|
|
292
|
+
|
|
293
|
+
For unusual deployments, `getPublicPageUrl` can override the public HTML URL and `getMarkdownUrl` can override the Copy Page, View as Markdown, and metadata URL. Most sites should use the package defaults so these surfaces cannot drift apart.
|
|
294
|
+
|
|
295
|
+
Set `openGraph.images` to `true` only when your site includes the Geistdocs OG route. Use `metadata` to set canonical URLs, `robots`, or custom Open Graph fields for a specific route. The `tableOfContent.header` and `tableOfContent.footer` slots render immediately above and below the table of contents.
|
|
271
296
|
|
|
272
297
|
## Package-owned runtime
|
|
273
298
|
|
|
@@ -88,6 +88,8 @@ Use `content/docs/meta.json` to control page order and groups:
|
|
|
88
88
|
}
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
Page and folder entries use names without extensions. A value such as `---Guides---` creates a non-clickable separator label. Read [Configure sidebar navigation](/docs/guides/nested-navigation) to add folder landing pages, deeply nested folders, custom links, and `defaultOpen` behavior.
|
|
92
|
+
|
|
91
93
|
## Configure the site
|
|
92
94
|
|
|
93
95
|
Use `geistdocs.tsx` to customize the site shell:
|