@vercel/geistdocs 2.15.4 → 2.16.0-canary.abbda54
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 +3 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/internal/navbar/mobile-menu.d.ts +3 -3
- package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
- package/dist/internal/navbar/mobile-menu.js +3 -3
- package/dist/internal/navbar/navbar-logo.d.ts +5 -3
- package/dist/internal/navbar/navbar-logo.d.ts.map +1 -1
- package/dist/internal/navbar/navbar-logo.js +71 -14
- package/dist/navbar.js +4 -3
- package/dist/next.d.ts +15 -2
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +27 -5
- package/dist/routes/search.d.ts +8 -1
- package/dist/routes/search.d.ts.map +1 -1
- package/dist/routes/search.js +120 -82
- package/dist/source-config.d.ts +2 -0
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +2 -0
- package/docs/agents.md +1 -1
- package/docs/llms.txt +84 -2
- package/docs/manifest.json +1 -1
- package/docs/pages/configuration.md +83 -1
- package/package.json +22 -9
- package/rehype-code-highlights.d.ts +13 -0
- package/rehype-code-highlights.js +278 -0
- package/search-index.d.ts +14 -0
- package/search-index.js +447 -0
- package/source-config-public.d.ts +15 -0
- package/source-config-public.js +47 -0
- package/source-config.js +2 -0
- package/template/AGENTS.md +4 -0
- package/template/app/api/search/route.ts +7 -2
- package/template/content/docs/configuration.mdx +83 -1
- package/template/lib/geistdocs/search-source.ts +6 -0
- package/template/next.config.ts +1 -1
- package/template/package.json +1 -1
- package/template/source.config.ts +1 -1
package/dist/routes/search.js
CHANGED
|
@@ -50,15 +50,25 @@ const getBreadcrumbs = (pageTree, url) => {
|
|
|
50
50
|
}
|
|
51
51
|
return breadcrumbs.length > 0 ? breadcrumbs : undefined;
|
|
52
52
|
};
|
|
53
|
-
export const createSearchRoute = ({ config, filterPage, source, sources, }) => {
|
|
53
|
+
export const createSearchRoute = ({ config, filterPage, loadSources, source, sources, }) => {
|
|
54
54
|
const translations = config.translations ?? {};
|
|
55
|
-
|
|
55
|
+
if (loadSources !== undefined &&
|
|
56
|
+
(source !== undefined || sources !== undefined)) {
|
|
57
|
+
throw new Error("createSearchRoute loadSources cannot be combined with source or sources.");
|
|
58
|
+
}
|
|
59
|
+
const routeSources = loadSources ? [] : resolveSources(source, sources);
|
|
56
60
|
const { defaultLanguage, languages } = getLanguages(config);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
let sourcesPromise;
|
|
62
|
+
const getSources = () => {
|
|
63
|
+
sourcesPromise ??= Promise.resolve()
|
|
64
|
+
.then(() => (loadSources ? loadSources() : routeSources))
|
|
65
|
+
.then((loaded) => resolveSources(undefined, loaded))
|
|
66
|
+
.catch((error) => {
|
|
67
|
+
sourcesPromise = undefined;
|
|
68
|
+
throw error;
|
|
69
|
+
});
|
|
70
|
+
return sourcesPromise;
|
|
71
|
+
};
|
|
62
72
|
const localeMap = Object.fromEntries(Object.entries(translations).map(([locale, translation]) => [
|
|
63
73
|
locale,
|
|
64
74
|
translation.displayName.toLowerCase(),
|
|
@@ -85,92 +95,120 @@ export const createSearchRoute = ({ config, filterPage, source, sources, }) => {
|
|
|
85
95
|
},
|
|
86
96
|
};
|
|
87
97
|
}
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
.
|
|
110
|
-
|
|
98
|
+
const initialize = async (locale) => {
|
|
99
|
+
const routeSources = await getSources();
|
|
100
|
+
const i18n = defineI18n({
|
|
101
|
+
defaultLanguage: locale,
|
|
102
|
+
languages: [locale],
|
|
103
|
+
hideLocale: "default-locale",
|
|
104
|
+
});
|
|
105
|
+
const indexes = routeSources.flatMap((source) => {
|
|
106
|
+
const pageTree = getPageTree(source, locale);
|
|
107
|
+
return getPages(source, locale)
|
|
108
|
+
.filter((page) => isPageVisibleForSurface(page, "search") &&
|
|
109
|
+
(filterPage?.(page, { lang: locale, source }) ?? true))
|
|
110
|
+
.map((page) => {
|
|
111
|
+
const data = page.data;
|
|
112
|
+
return {
|
|
113
|
+
id: page.url,
|
|
114
|
+
title: resolveDocumentTitle({
|
|
115
|
+
pageTitle: data.title ?? page.url,
|
|
116
|
+
pageUrl: page.url,
|
|
117
|
+
tree: pageTree,
|
|
118
|
+
}),
|
|
119
|
+
description: data.description ?? "",
|
|
120
|
+
keywords: data.keywords ?? [],
|
|
121
|
+
content: [
|
|
122
|
+
...(data.structuredData?.headings ?? []),
|
|
123
|
+
...(data.structuredData?.contents ?? []),
|
|
124
|
+
]
|
|
125
|
+
.map((section) => section.content)
|
|
126
|
+
.join("\n"),
|
|
127
|
+
breadcrumbs: getBreadcrumbs(pageTree, page.url),
|
|
128
|
+
locale,
|
|
129
|
+
structuredData: data.structuredData ?? {
|
|
130
|
+
contents: [],
|
|
131
|
+
headings: [],
|
|
132
|
+
},
|
|
133
|
+
url: page.url,
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
const rankingIndex = prepareSearchIndex(indexes, locale);
|
|
138
|
+
const sections = createI18nSearchAPI("advanced", {
|
|
139
|
+
i18n,
|
|
140
|
+
indexes,
|
|
141
|
+
localeMap,
|
|
142
|
+
});
|
|
143
|
+
const pageSearch = {
|
|
144
|
+
// Page metadata must outweigh incidental mentions in paragraphs/tables.
|
|
145
|
+
boost: { title: 8, keywords: 6, description: 2, content: 1 },
|
|
146
|
+
properties: ["title", "keywords", "description", "content"],
|
|
147
|
+
// Retrieve all candidates; verify English term coverage during ranking.
|
|
148
|
+
threshold: 1,
|
|
149
|
+
tolerance: 0,
|
|
150
|
+
// Apply page limits after verifying query coverage and exact matches.
|
|
151
|
+
limit: indexes.length,
|
|
152
|
+
};
|
|
153
|
+
const pages = createI18nSearchAPI("simple", {
|
|
154
|
+
i18n,
|
|
155
|
+
localeMap: Object.fromEntries(Object.entries(localeMap).map(([locale, options]) => [
|
|
111
156
|
locale,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
157
|
+
typeof options === "object"
|
|
158
|
+
? {
|
|
159
|
+
components: options.components,
|
|
160
|
+
search: {
|
|
161
|
+
...pageSearch,
|
|
162
|
+
threshold: options.search && "threshold" in options.search
|
|
163
|
+
? options.search.threshold
|
|
164
|
+
: pageSearch.threshold,
|
|
165
|
+
},
|
|
166
|
+
}
|
|
167
|
+
: options,
|
|
168
|
+
])),
|
|
169
|
+
indexes: indexes.map((page) => ({
|
|
170
|
+
...page,
|
|
171
|
+
keywords: page.keywords.join(" "),
|
|
172
|
+
})),
|
|
173
|
+
search: pageSearch,
|
|
118
174
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
175
|
+
// Fumadocs creates its databases asynchronously without exposing a ready
|
|
176
|
+
// promise. Await both through search so database failures evict this init,
|
|
177
|
+
// including when the first request will use only the vector endpoint.
|
|
178
|
+
await Promise.all([
|
|
179
|
+
pages.search("", { locale }),
|
|
180
|
+
sections.search("", { locale }),
|
|
181
|
+
]);
|
|
182
|
+
return { pages, sections, rankingIndex };
|
|
183
|
+
};
|
|
184
|
+
// Allocate cache entries only from configuration, never from request input.
|
|
185
|
+
const initializations = new Map(languages.map((locale) => [
|
|
122
186
|
locale,
|
|
123
|
-
|
|
187
|
+
undefined,
|
|
124
188
|
]));
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
threshold: 1,
|
|
136
|
-
tolerance: 0,
|
|
137
|
-
// Apply page limits after verifying query coverage and exact matches.
|
|
138
|
-
limit: indexes.length,
|
|
189
|
+
const getSearch = (locale) => {
|
|
190
|
+
let initialization = initializations.get(locale);
|
|
191
|
+
if (!initialization) {
|
|
192
|
+
initialization = initialize(locale).catch((error) => {
|
|
193
|
+
initializations.set(locale, undefined);
|
|
194
|
+
throw error;
|
|
195
|
+
});
|
|
196
|
+
initializations.set(locale, initialization);
|
|
197
|
+
}
|
|
198
|
+
return initialization;
|
|
139
199
|
};
|
|
140
|
-
const pages = createI18nSearchAPI("simple", {
|
|
141
|
-
i18n,
|
|
142
|
-
localeMap: Object.fromEntries(Object.entries(localeMap).map(([locale, options]) => [
|
|
143
|
-
locale,
|
|
144
|
-
typeof options === "object"
|
|
145
|
-
? {
|
|
146
|
-
components: options.components,
|
|
147
|
-
search: {
|
|
148
|
-
...pageSearch,
|
|
149
|
-
threshold: options.search && "threshold" in options.search
|
|
150
|
-
? options.search.threshold
|
|
151
|
-
: pageSearch.threshold,
|
|
152
|
-
},
|
|
153
|
-
}
|
|
154
|
-
: options,
|
|
155
|
-
])),
|
|
156
|
-
indexes: indexes.map((page) => ({
|
|
157
|
-
...page,
|
|
158
|
-
keywords: page.keywords.join(" "),
|
|
159
|
-
})),
|
|
160
|
-
search: pageSearch,
|
|
161
|
-
});
|
|
162
200
|
return async (request) => {
|
|
163
201
|
const url = new URL(request.url);
|
|
164
|
-
if (url.searchParams.get("mode") === "vector") {
|
|
165
|
-
return sections.GET(request);
|
|
166
|
-
}
|
|
167
202
|
const locale = url.searchParams.get("locale") ?? defaultLanguage;
|
|
168
203
|
const query = url.searchParams.get("query") ?? "";
|
|
169
|
-
|
|
170
|
-
const rankingIndex = rankingIndexes.get(locale);
|
|
171
|
-
if (!(searchQuery && rankingIndex)) {
|
|
204
|
+
if (!(initializations.has(locale) && query.trim())) {
|
|
172
205
|
return Response.json([]);
|
|
173
206
|
}
|
|
207
|
+
const { pages, sections, rankingIndex } = await getSearch(locale);
|
|
208
|
+
if (url.searchParams.get("mode") === "vector") {
|
|
209
|
+
return sections.GET(request);
|
|
210
|
+
}
|
|
211
|
+
const searchQuery = prepareSearchQuery(query, locale);
|
|
174
212
|
const tag = url.searchParams.get("tag")?.split(",");
|
|
175
213
|
const [pageResults, sectionResults] = await Promise.all([
|
|
176
214
|
pages.search(searchQuery, { locale }),
|
package/dist/source-config.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ type FumadocsConfigInput = NonNullable<Parameters<typeof defineFumadocsConfig>[0
|
|
|
5
5
|
export interface GeistdocsSourceConfigOptions {
|
|
6
6
|
mdxOptions?: DefaultMDXOptions;
|
|
7
7
|
plugins?: FumadocsConfigInput["plugins"];
|
|
8
|
+
/** Generate search-only collections in .source/search (adds a remark pass). */
|
|
9
|
+
searchIndex?: boolean;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Builds the remark pipeline from Fumadocs' resolved defaults.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-config.d.ts","sourceRoot":"","sources":["../src/source-config.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,IAAI,oBAAoB,EAGrC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"source-config.d.ts","sourceRoot":"","sources":["../src/source-config.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,IAAI,oBAAoB,EAGrC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACzC,+EAA+E;IAC/E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAQD;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,GACxC,UAAU,SAAS,EAAE,EACrB,kBAAiB,SAAS,EAAO,KAChC,SAAS,EAgBX,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAsG3B,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwCrC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;iBAAa,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GACxC,iBAAiB,iBAAiB,CAAC,eAAe,CAAC,KAClD,WAAW,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAKhD,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,SAAQ,4BAAiC,+CA4B1C,CAAC"}
|
package/dist/source-config.js
CHANGED
|
@@ -4,6 +4,7 @@ import lastModified from "fumadocs-mdx/plugins/last-modified";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { rehypeTaskListLabels } from "../rehype-task-list-labels.js";
|
|
6
6
|
import { remarkDetails } from "../remark-details.js";
|
|
7
|
+
import { searchIndex } from "../search-index.js";
|
|
7
8
|
import { getLastModified } from "./internal/last-modified.js";
|
|
8
9
|
const pluginOf = (entry) => Array.isArray(entry) ? entry[0] : entry;
|
|
9
10
|
const indexOfPlugin = (list, plugin) => list.findIndex((entry) => pluginOf(entry) === plugin);
|
|
@@ -195,6 +196,7 @@ export const defineGeistdocsSourceConfig = (config = {}) => {
|
|
|
195
196
|
plugins: [
|
|
196
197
|
lastModified({ versionControl: getLastModified }),
|
|
197
198
|
...existingPlugins,
|
|
199
|
+
...(config.searchIndex ? [searchIndex()] : []),
|
|
198
200
|
],
|
|
199
201
|
});
|
|
200
202
|
};
|
package/docs/agents.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Geistdocs Package Docs
|
|
2
2
|
|
|
3
|
-
These docs are bundled with `@vercel/geistdocs` 2.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.16.0-canary.abbda54 so agents can understand the installed package without web access.
|
|
4
4
|
They are generated from `apps/template/content/docs` during the package build.
|
|
5
5
|
|
|
6
6
|
## How to use these files
|
package/docs/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Geistdocs Package Documentation
|
|
2
2
|
|
|
3
|
-
These docs are bundled with `@vercel/geistdocs` 2.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.16.0-canary.abbda54.
|
|
4
4
|
They describe how to build package-backed Geistdocs sites and how to use the package APIs from generated project adapters.
|
|
5
5
|
|
|
6
6
|
## Documentation Index
|
|
@@ -1244,7 +1244,7 @@ export const navbarBrand: GeistdocsNavbarBrand = "labs";
|
|
|
1244
1244
|
|
|
1245
1245
|
The generated `lib/geistdocs/config.tsx` forwards this export to `defineConfig`. Existing sites can forward it in their adapter or set `navbarBrand: "labs"` directly in `defineConfig`. Private projects use the type from `@vercel/geistdocs-private/config`.
|
|
1246
1246
|
|
|
1247
|
-
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes.
|
|
1247
|
+
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes. Set `navbarVariant: "vercel-labs"` in `defineConfig` to use the Labs mark and show the Labs products and experiments menu. The previous `"standard"` value remains supported as an alias for `"vercel"`. The `"oss"` (default) layout keeps your project's `Logo` and `logoHref` separate from the brand and shows the OSS product menu. The `"vercel"` layout shows the selected brand mark, with no separator, project logo, or product menu.
|
|
1248
1248
|
|
|
1249
1249
|
For new projects, both CLIs accept `--brand labs`; omitting it or using `--brand vercel` preserves the defaults. See [Create a Labs starter](/docs/getting-started#create-a-labs-starter).
|
|
1250
1250
|
|
|
@@ -1424,6 +1424,88 @@ export const docs = defineDocs({
|
|
|
1424
1424
|
export default defineGeistdocsSourceConfig();
|
|
1425
1425
|
```
|
|
1426
1426
|
|
|
1427
|
+
### Search-only collections
|
|
1428
|
+
|
|
1429
|
+
Enable generation of search data without compiled page bodies:
|
|
1430
|
+
|
|
1431
|
+
```ts title="source.config.ts"
|
|
1432
|
+
export default defineGeistdocsSourceConfig({ searchIndex: true });
|
|
1433
|
+
```
|
|
1434
|
+
|
|
1435
|
+
Also enable preparation in the Next wrapper. It waits for codegen before bundling
|
|
1436
|
+
and skips source extraction in `next start`:
|
|
1437
|
+
|
|
1438
|
+
```ts title="next.config.ts"
|
|
1439
|
+
const withGeistdocs = createGeistdocs({ searchIndex: true });
|
|
1440
|
+
export default withGeistdocs(config);
|
|
1441
|
+
```
|
|
1442
|
+
|
|
1443
|
+
With this option, the wrapper returns a phase-aware Next config function. Export
|
|
1444
|
+
it directly as above; apply other Next config wrappers to `config` first.
|
|
1445
|
+
|
|
1446
|
+
Run your existing `fumadocs-mdx` postinstall command to generate
|
|
1447
|
+
`.source/search/<collection>.ts`. Each module exports a collection compatible
|
|
1448
|
+
with `createSource`; its frontmatter, sections, and metadata contain no MDX
|
|
1449
|
+
imports. Keep the same source options (base URL, slugs, locales, page-tree
|
|
1450
|
+
customization) as your rendering source, in a shared module that does not import
|
|
1451
|
+
`.source/server`.
|
|
1452
|
+
|
|
1453
|
+
```ts title="lib/geistdocs/search-source.ts"
|
|
1454
|
+
import { createSource } from "@vercel/geistdocs/source";
|
|
1455
|
+
import docs from "@/.source/search/docs";
|
|
1456
|
+
import { config } from "./config";
|
|
1457
|
+
|
|
1458
|
+
export const searchSource = createSource({ docs, config });
|
|
1459
|
+
```
|
|
1460
|
+
|
|
1461
|
+
```ts title="app/api/search/route.ts"
|
|
1462
|
+
import { createSearchRoute } from "@vercel/geistdocs/routes/search";
|
|
1463
|
+
import { config } from "@/lib/geistdocs/config";
|
|
1464
|
+
|
|
1465
|
+
export const GET = createSearchRoute({
|
|
1466
|
+
config,
|
|
1467
|
+
loadSources: async () => {
|
|
1468
|
+
const { searchSource } = await import("@/lib/geistdocs/search-source");
|
|
1469
|
+
return [searchSource];
|
|
1470
|
+
},
|
|
1471
|
+
});
|
|
1472
|
+
```
|
|
1473
|
+
|
|
1474
|
+
Use either `loadSources` or the existing `source`/`sources` options. Concurrent
|
|
1475
|
+
requests share initialization; a failed initialization can be retried. Only the
|
|
1476
|
+
requested locale's indexes are built. For versioned sites, create one lazy route
|
|
1477
|
+
per version and dispatch to it using your existing version selector. Do not
|
|
1478
|
+
import a barrel that also loads the rendering sources.
|
|
1479
|
+
|
|
1480
|
+
The generator runs the collection's schemas, frontmatter/VFile/metadata hooks,
|
|
1481
|
+
and resolved remark plugins, including Markdown includes. It skips highlighting,
|
|
1482
|
+
rehype, and recma, and adds a separate remark pass during codegen. Custom search
|
|
1483
|
+
content must be recorded in `structuredData` by the remark pipeline. Collection
|
|
1484
|
+
MDX overrides must retain `remarkStructure`. Metadata must serialize as JSON
|
|
1485
|
+
values or Dates; custom runtime exports, page bodies, and Markdown methods are
|
|
1486
|
+
not available on search-only pages. Filters must use stable metadata, not render
|
|
1487
|
+
or load page bodies. Keep generated modules server-only: internal pages and
|
|
1488
|
+
custom metadata may be present, with `internal`, `excludeFrom`, and `filterPage`
|
|
1489
|
+
applied by the search route before returning results.
|
|
1490
|
+
|
|
1491
|
+
This works in development, previews, and production, in both packages. Content,
|
|
1492
|
+
metadata, and registered include dependencies regenerate on edits; generation
|
|
1493
|
+
errors invalidate old output and fail production/codegen commands. Orama still
|
|
1494
|
+
builds its indexes on first search. Keep `.source/server` for docs rendering,
|
|
1495
|
+
Markdown exports, and chat.
|
|
1496
|
+
|
|
1497
|
+
### Code highlighter (public package)
|
|
1498
|
+
|
|
1499
|
+
The public package uses [Highlights](https://diffs.com/highlights), which tokenizes code with WebAssembly lexers while keeping the JavaScript MDX compiler. Geist colors, titles, icons, tabs and `[!code ...]` annotations are preserved. Some token colors differ from Shiki, and unsupported languages render as plain text. To use Shiki's TextMate grammars instead, pass `highlighter: "shiki"`:
|
|
1500
|
+
|
|
1501
|
+
```ts title="source.config.ts"
|
|
1502
|
+
export default defineGeistdocsSourceConfig({ highlighter: "shiki" });
|
|
1503
|
+
```
|
|
1504
|
+
|
|
1505
|
+
Set `highlighter: false` or `mdxOptions.rehypeCodeOptions: false` to disable built-in highlighting when providing your own plugin. A `rehypePlugins` callback can also remove or replace Fumadocs' default highlighter without Highlights being added back.
|
|
1506
|
+
|
|
1507
|
+
The private package retains its existing Shiki pipeline. The `highlighter` option above is available only in the public package.
|
|
1508
|
+
|
|
1427
1509
|
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.
|
|
1428
1510
|
|
|
1429
1511
|
## Page URLs
|
package/docs/manifest.json
CHANGED
|
@@ -105,7 +105,7 @@ export const navbarBrand: GeistdocsNavbarBrand = "labs";
|
|
|
105
105
|
|
|
106
106
|
The generated `lib/geistdocs/config.tsx` forwards this export to `defineConfig`. Existing sites can forward it in their adapter or set `navbarBrand: "labs"` directly in `defineConfig`. Private projects use the type from `@vercel/geistdocs-private/config`.
|
|
107
107
|
|
|
108
|
-
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes.
|
|
108
|
+
Labs links to [vercel.com/labs](https://vercel.com/labs) and adapts to light and dark themes. Set `navbarVariant: "vercel-labs"` in `defineConfig` to use the Labs mark and show the Labs products and experiments menu. The previous `"standard"` value remains supported as an alias for `"vercel"`. The `"oss"` (default) layout keeps your project's `Logo` and `logoHref` separate from the brand and shows the OSS product menu. The `"vercel"` layout shows the selected brand mark, with no separator, project logo, or product menu.
|
|
109
109
|
|
|
110
110
|
For new projects, both CLIs accept `--brand labs`; omitting it or using `--brand vercel` preserves the defaults. See [Create a Labs starter](/docs/getting-started#create-a-labs-starter).
|
|
111
111
|
|
|
@@ -285,6 +285,88 @@ export const docs = defineDocs({
|
|
|
285
285
|
export default defineGeistdocsSourceConfig();
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
+
### Search-only collections
|
|
289
|
+
|
|
290
|
+
Enable generation of search data without compiled page bodies:
|
|
291
|
+
|
|
292
|
+
```ts title="source.config.ts"
|
|
293
|
+
export default defineGeistdocsSourceConfig({ searchIndex: true });
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Also enable preparation in the Next wrapper. It waits for codegen before bundling
|
|
297
|
+
and skips source extraction in `next start`:
|
|
298
|
+
|
|
299
|
+
```ts title="next.config.ts"
|
|
300
|
+
const withGeistdocs = createGeistdocs({ searchIndex: true });
|
|
301
|
+
export default withGeistdocs(config);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
With this option, the wrapper returns a phase-aware Next config function. Export
|
|
305
|
+
it directly as above; apply other Next config wrappers to `config` first.
|
|
306
|
+
|
|
307
|
+
Run your existing `fumadocs-mdx` postinstall command to generate
|
|
308
|
+
`.source/search/<collection>.ts`. Each module exports a collection compatible
|
|
309
|
+
with `createSource`; its frontmatter, sections, and metadata contain no MDX
|
|
310
|
+
imports. Keep the same source options (base URL, slugs, locales, page-tree
|
|
311
|
+
customization) as your rendering source, in a shared module that does not import
|
|
312
|
+
`.source/server`.
|
|
313
|
+
|
|
314
|
+
```ts title="lib/geistdocs/search-source.ts"
|
|
315
|
+
import { createSource } from "@vercel/geistdocs/source";
|
|
316
|
+
import docs from "@/.source/search/docs";
|
|
317
|
+
import { config } from "./config";
|
|
318
|
+
|
|
319
|
+
export const searchSource = createSource({ docs, config });
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
```ts title="app/api/search/route.ts"
|
|
323
|
+
import { createSearchRoute } from "@vercel/geistdocs/routes/search";
|
|
324
|
+
import { config } from "@/lib/geistdocs/config";
|
|
325
|
+
|
|
326
|
+
export const GET = createSearchRoute({
|
|
327
|
+
config,
|
|
328
|
+
loadSources: async () => {
|
|
329
|
+
const { searchSource } = await import("@/lib/geistdocs/search-source");
|
|
330
|
+
return [searchSource];
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Use either `loadSources` or the existing `source`/`sources` options. Concurrent
|
|
336
|
+
requests share initialization; a failed initialization can be retried. Only the
|
|
337
|
+
requested locale's indexes are built. For versioned sites, create one lazy route
|
|
338
|
+
per version and dispatch to it using your existing version selector. Do not
|
|
339
|
+
import a barrel that also loads the rendering sources.
|
|
340
|
+
|
|
341
|
+
The generator runs the collection's schemas, frontmatter/VFile/metadata hooks,
|
|
342
|
+
and resolved remark plugins, including Markdown includes. It skips highlighting,
|
|
343
|
+
rehype, and recma, and adds a separate remark pass during codegen. Custom search
|
|
344
|
+
content must be recorded in `structuredData` by the remark pipeline. Collection
|
|
345
|
+
MDX overrides must retain `remarkStructure`. Metadata must serialize as JSON
|
|
346
|
+
values or Dates; custom runtime exports, page bodies, and Markdown methods are
|
|
347
|
+
not available on search-only pages. Filters must use stable metadata, not render
|
|
348
|
+
or load page bodies. Keep generated modules server-only: internal pages and
|
|
349
|
+
custom metadata may be present, with `internal`, `excludeFrom`, and `filterPage`
|
|
350
|
+
applied by the search route before returning results.
|
|
351
|
+
|
|
352
|
+
This works in development, previews, and production, in both packages. Content,
|
|
353
|
+
metadata, and registered include dependencies regenerate on edits; generation
|
|
354
|
+
errors invalidate old output and fail production/codegen commands. Orama still
|
|
355
|
+
builds its indexes on first search. Keep `.source/server` for docs rendering,
|
|
356
|
+
Markdown exports, and chat.
|
|
357
|
+
|
|
358
|
+
### Code highlighter (public package)
|
|
359
|
+
|
|
360
|
+
The public package uses [Highlights](https://diffs.com/highlights), which tokenizes code with WebAssembly lexers while keeping the JavaScript MDX compiler. Geist colors, titles, icons, tabs and `[!code ...]` annotations are preserved. Some token colors differ from Shiki, and unsupported languages render as plain text. To use Shiki's TextMate grammars instead, pass `highlighter: "shiki"`:
|
|
361
|
+
|
|
362
|
+
```ts title="source.config.ts"
|
|
363
|
+
export default defineGeistdocsSourceConfig({ highlighter: "shiki" });
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Set `highlighter: false` or `mdxOptions.rehypeCodeOptions: false` to disable built-in highlighting when providing your own plugin. A `rehypePlugins` callback can also remove or replace Fumadocs' default highlighter without Highlights being added back.
|
|
367
|
+
|
|
368
|
+
The private package retains its existing Shiki pipeline. The `highlighter` option above is available only in the public package.
|
|
369
|
+
|
|
288
370
|
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.
|
|
289
371
|
|
|
290
372
|
## Page URLs
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/geistdocs",
|
|
3
3
|
"description": "Runtime and CLI for Geistdocs projects.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.16.0-canary.abbda54",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -27,17 +27,23 @@
|
|
|
27
27
|
"cli.js",
|
|
28
28
|
"dist",
|
|
29
29
|
"docs",
|
|
30
|
+
"rehype-code-highlights.d.ts",
|
|
31
|
+
"rehype-code-highlights.js",
|
|
30
32
|
"rehype-task-list-labels.d.ts",
|
|
31
33
|
"rehype-task-list-labels.js",
|
|
32
34
|
"remark-details.d.ts",
|
|
33
35
|
"remark-details.js",
|
|
34
36
|
"source-config.js",
|
|
37
|
+
"source-config-public.js",
|
|
38
|
+
"source-config-public.d.ts",
|
|
35
39
|
"template",
|
|
36
40
|
"public-foundation.css",
|
|
37
41
|
"shared-theme.css",
|
|
38
42
|
"styles.css",
|
|
39
43
|
"theme.css",
|
|
40
|
-
"LICENSE"
|
|
44
|
+
"LICENSE",
|
|
45
|
+
"search-index.js",
|
|
46
|
+
"search-index.d.ts"
|
|
41
47
|
],
|
|
42
48
|
"exports": {
|
|
43
49
|
"./changelog": {
|
|
@@ -161,8 +167,8 @@
|
|
|
161
167
|
"default": "./dist/providers/public/utils.js"
|
|
162
168
|
},
|
|
163
169
|
"./source-config": {
|
|
164
|
-
"types": "./
|
|
165
|
-
"default": "./source-config.js"
|
|
170
|
+
"types": "./source-config-public.d.ts",
|
|
171
|
+
"default": "./source-config-public.js"
|
|
166
172
|
},
|
|
167
173
|
"./docs/agents.md": "./docs/agents.md",
|
|
168
174
|
"./docs/llms.txt": "./docs/llms.txt",
|
|
@@ -301,12 +307,19 @@
|
|
|
301
307
|
"./theme.css": "./theme.css",
|
|
302
308
|
"./package.json": "./package.json"
|
|
303
309
|
},
|
|
310
|
+
"scripts": {
|
|
311
|
+
"build": "rm -rf dist docs template && node ./scripts/bundle-template.mjs && node ./scripts/bundle-docs.mjs && tsc -p tsconfig.runtime.json && tsup --config tsup.config.cli.ts",
|
|
312
|
+
"dev": "tsc -p tsconfig.runtime.json --watch --preserveWatchOutput"
|
|
313
|
+
},
|
|
304
314
|
"dependencies": {
|
|
305
315
|
"@ai-sdk/react": "^3.0.134",
|
|
306
316
|
"@clack/prompts": "^0.11.0",
|
|
317
|
+
"@mdx-js/mdx": "^3.1.1",
|
|
307
318
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
308
319
|
"@next/env": "16.3.3",
|
|
309
320
|
"@orama/tokenizers": "^3.1.16",
|
|
321
|
+
"@pierre/highlights": "0.5.1",
|
|
322
|
+
"@shikijs/rehype": "3.19.0",
|
|
310
323
|
"@streamdown/cjk": "^1.0.1",
|
|
311
324
|
"@types/mdx": "^2.0.13",
|
|
312
325
|
"@types/react": "^19.2.7",
|
|
@@ -323,6 +336,7 @@
|
|
|
323
336
|
"fumadocs-ui": "16.2.2",
|
|
324
337
|
"geist": "1.7.1",
|
|
325
338
|
"glob": "^11.0.0",
|
|
339
|
+
"js-yaml": "^4.1.1",
|
|
326
340
|
"mcp-handler": "2.2.0",
|
|
327
341
|
"mermaid": "^11.12.2",
|
|
328
342
|
"next-themes": "^0.4.6",
|
|
@@ -335,15 +349,18 @@
|
|
|
335
349
|
"remark-mdx": "^3.1.1",
|
|
336
350
|
"remark-parse": "^11.0.0",
|
|
337
351
|
"remark-stringify": "^11.0.0",
|
|
352
|
+
"shiki": "3.19.0",
|
|
338
353
|
"sonner": "^2.0.8",
|
|
339
354
|
"streamdown": "^2.1.0",
|
|
340
355
|
"tailwind-merge": "^3.4.0",
|
|
356
|
+
"tinyglobby": "^0.2.15",
|
|
341
357
|
"ts-morph": "^27.0.2",
|
|
342
358
|
"tw-animate-css": "^1.4.0",
|
|
343
359
|
"unified": "^11.0.5",
|
|
344
360
|
"unist-util-visit": "^5.1.0",
|
|
345
361
|
"use-stick-to-bottom": "^1.1.1",
|
|
346
362
|
"vaul": "^1.1.2",
|
|
363
|
+
"vfile": "^6.0.3",
|
|
347
364
|
"zod": "^4.6.5"
|
|
348
365
|
},
|
|
349
366
|
"peerDependencies": {
|
|
@@ -364,9 +381,5 @@
|
|
|
364
381
|
"react-dom": "^19.2.3",
|
|
365
382
|
"tsup": "^8.5.1",
|
|
366
383
|
"typescript": "^5.9.3"
|
|
367
|
-
},
|
|
368
|
-
"scripts": {
|
|
369
|
-
"build": "rm -rf dist docs template && node ./scripts/bundle-template.mjs && node ./scripts/bundle-docs.mjs && tsc -p tsconfig.runtime.json && tsup --config tsup.config.cli.ts",
|
|
370
|
-
"dev": "tsc -p tsconfig.runtime.json --watch --preserveWatchOutput"
|
|
371
384
|
}
|
|
372
|
-
}
|
|
385
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RehypeCodeOptions } from "fumadocs-core/mdx-plugins";
|
|
2
|
+
import type { Root } from "hast";
|
|
3
|
+
|
|
4
|
+
/** Zed-format Geist theme for @pierre/highlights, using Geist's Shiki CSS variables. */
|
|
5
|
+
export declare const geistHighlightsTheme: Record<string, unknown>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Drop-in for Fumadocs' `rehypeCode` that tokenizes with
|
|
9
|
+
* @pierre/highlights while keeping Shiki's HAST output and transformers.
|
|
10
|
+
*/
|
|
11
|
+
export declare const rehypeCodeHighlights: (
|
|
12
|
+
options?: Partial<RehypeCodeOptions>
|
|
13
|
+
) => (tree: Root, file: unknown) => Promise<void>;
|