@vercel/geistdocs 2.15.4-canary.2a54b38 → 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.
Files changed (81) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/config.d.ts +3 -3
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/internal/mdx-to-markdown.d.ts.map +1 -1
  5. package/dist/internal/mdx-to-markdown.js +0 -9
  6. package/dist/internal/navbar/mobile-menu.d.ts +3 -3
  7. package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
  8. package/dist/internal/navbar/mobile-menu.js +3 -3
  9. package/dist/internal/navbar/navbar-logo.d.ts +5 -3
  10. package/dist/internal/navbar/navbar-logo.d.ts.map +1 -1
  11. package/dist/internal/navbar/navbar-logo.js +71 -14
  12. package/dist/internal/page-actions.d.ts +4 -4
  13. package/dist/internal/page-actions.d.ts.map +1 -1
  14. package/dist/internal/page-actions.js +1 -6
  15. package/dist/mdx.d.ts +25 -3
  16. package/dist/mdx.d.ts.map +1 -1
  17. package/dist/mdx.js +61 -8
  18. package/dist/navbar.js +4 -3
  19. package/dist/next.d.ts +15 -12
  20. package/dist/next.d.ts.map +1 -1
  21. package/dist/next.js +28 -86
  22. package/dist/pages/docs.d.ts +98 -5
  23. package/dist/pages/docs.d.ts.map +1 -1
  24. package/dist/pages/docs.js +250 -13
  25. package/dist/routes/search.d.ts +8 -1
  26. package/dist/routes/search.d.ts.map +1 -1
  27. package/dist/routes/search.js +120 -82
  28. package/dist/source-config.d.ts +3 -10
  29. package/dist/source-config.d.ts.map +1 -1
  30. package/dist/source-config.js +12 -21
  31. package/dist/source.d.ts +17 -6
  32. package/dist/source.d.ts.map +1 -1
  33. package/dist/source.js +75 -2
  34. package/docs/agents.md +1 -1
  35. package/docs/llms.txt +70 -14
  36. package/docs/manifest.json +1 -1
  37. package/docs/pages/configuration.md +69 -13
  38. package/package.json +20 -35
  39. package/rehype-code-highlights.d.ts +1 -1
  40. package/rehype-code-highlights.js +49 -1
  41. package/search-index.d.ts +14 -0
  42. package/search-index.js +447 -0
  43. package/source-config-public.d.ts +15 -0
  44. package/source-config-public.js +47 -0
  45. package/source-config.js +12 -27
  46. package/template/AGENTS.md +4 -0
  47. package/template/app/api/search/route.ts +7 -2
  48. package/template/content/docs/configuration.mdx +69 -13
  49. package/template/lib/geistdocs/search-source.ts +6 -0
  50. package/template/next.config.ts +1 -1
  51. package/template/package.json +4 -7
  52. package/template/source.config.ts +1 -1
  53. package/dist/internal/source-loader.d.ts +0 -28
  54. package/dist/internal/source-loader.d.ts.map +0 -1
  55. package/dist/internal/source-loader.js +0 -77
  56. package/dist/mdx-basic.d.ts +0 -27
  57. package/dist/mdx-basic.d.ts.map +0 -1
  58. package/dist/mdx-basic.js +0 -61
  59. package/dist/navigation.d.ts +0 -11
  60. package/dist/navigation.d.ts.map +0 -1
  61. package/dist/navigation.js +0 -8
  62. package/dist/pages/docs-custom.d.ts +0 -111
  63. package/dist/pages/docs-custom.d.ts.map +0 -1
  64. package/dist/pages/docs-custom.js +0 -250
  65. package/native-mdx/LICENSE-mdxjs-rs +0 -22
  66. package/native-mdx/UPSTREAM.md +0 -16
  67. package/native-mdx/binaries/darwin-arm64.node +0 -0
  68. package/native-mdx/binaries/linux-x64-gnu.node +0 -0
  69. package/native-mdx/data-entry.d.mts +0 -15
  70. package/native-mdx/data-entry.mjs +0 -97
  71. package/native-mdx/data-projection.mjs +0 -205
  72. package/native-mdx/fumadocs-adapter.mjs +0 -36
  73. package/native-mdx/index-emitter.mjs +0 -34
  74. package/native-mdx/loader-data.cjs +0 -36
  75. package/native-mdx/loader-mdx.cjs +0 -9
  76. package/native-mdx/loader-mdx.mjs +0 -419
  77. package/native-mdx/native-binding.cjs +0 -27
  78. package/native-mdx/navigation-entry.d.mts +0 -11
  79. package/native-mdx/navigation-entry.mjs +0 -136
  80. package/native-mdx/navigation-title.mjs +0 -53
  81. package/template/pnpm-workspace.yaml +0 -3
@@ -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
- const routeSources = resolveSources(source, sources);
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
- const i18n = defineI18n({
58
- defaultLanguage,
59
- languages,
60
- hideLocale: "default-locale",
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 getIndexes = () => languages.flatMap((locale) => routeSources.flatMap((source) => {
89
- const pageTree = getPageTree(source, locale);
90
- return getPages(source, locale)
91
- .filter((page) => isPageVisibleForSurface(page, "search") &&
92
- (filterPage?.(page, { lang: locale, source }) ?? true))
93
- .map((page) => {
94
- const data = page.data;
95
- return {
96
- id: page.url,
97
- title: resolveDocumentTitle({
98
- pageTitle: data.title ?? page.url,
99
- pageUrl: page.url,
100
- tree: pageTree,
101
- }),
102
- description: data.description ?? "",
103
- keywords: data.keywords ?? [],
104
- content: [
105
- ...(data.structuredData?.headings ?? []),
106
- ...(data.structuredData?.contents ?? []),
107
- ]
108
- .map((section) => section.content)
109
- .join("\n"),
110
- breadcrumbs: getBreadcrumbs(pageTree, page.url),
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
- structuredData: data.structuredData ?? {
113
- contents: [],
114
- headings: [],
115
- },
116
- url: page.url,
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
- const indexes = getIndexes();
121
- const rankingIndexes = new Map(languages.map((locale) => [
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
- prepareSearchIndex(indexes.filter((page) => page.locale === locale), locale),
187
+ undefined,
124
188
  ]));
125
- const sections = createI18nSearchAPI("advanced", {
126
- i18n,
127
- indexes,
128
- localeMap,
129
- });
130
- const pageSearch = {
131
- // Page metadata must outweigh incidental mentions in paragraphs/tables.
132
- boost: { title: 8, keywords: 6, description: 2, content: 1 },
133
- properties: ["title", "keywords", "description", "content"],
134
- // Retrieve all candidates; verify English term coverage during ranking.
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
- const searchQuery = prepareSearchQuery(query, locale);
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 }),
@@ -3,17 +3,10 @@ import type { Pluggable } from "unified";
3
3
  import { z } from "zod";
4
4
  type FumadocsConfigInput = NonNullable<Parameters<typeof defineFumadocsConfig>[0]>;
5
5
  export interface GeistdocsSourceConfigOptions {
6
- /**
7
- * Code block highlighter. `highlights` tokenizes with @pierre/highlights'
8
- * Wasm lexers, keeping Shiki's HTML output and Fumadocs' code block
9
- * transformers. `shiki` uses Shiki's TextMate grammars, for languages
10
- * Highlights doesn't support or custom grammars. false disables built-in highlighting.
11
- *
12
- * @defaultValue "highlights"
13
- */
14
- highlighter?: "shiki" | "highlights" | false;
15
6
  mdxOptions?: DefaultMDXOptions;
16
7
  plugins?: FumadocsConfigInput["plugins"];
8
+ /** Generate search-only collections in .source/search (adds a remark pass). */
9
+ searchIndex?: boolean;
17
10
  }
18
11
  /**
19
12
  * Builds the remark pipeline from Fumadocs' resolved defaults.
@@ -90,7 +83,7 @@ export declare const geistdocsMetaSchema: z.ZodObject<{
90
83
  * Fumadocs, which places it among its defaults; a function receives those
91
84
  * defaults and returns the final list.
92
85
  */
93
- export declare const resolveGeistdocsRehypePlugins: (consumerPlugins: DefaultMDXOptions["rehypePlugins"], leadingPlugins?: Pluggable[]) => NonNullable<DefaultMDXOptions["rehypePlugins"]>;
86
+ export declare const resolveGeistdocsRehypePlugins: (consumerPlugins: DefaultMDXOptions["rehypePlugins"]) => NonNullable<DefaultMDXOptions["rehypePlugins"]>;
94
87
  export declare const defineGeistdocsSourceConfig: (config?: GeistdocsSourceConfigOptions) => import("fumadocs-mdx/config").GlobalConfig;
95
88
  export {};
96
89
  //# sourceMappingURL=source-config.d.ts.map
@@ -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;AAMxB,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,KAAK,CAAC;IAC7C,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CAC1C;AAQD;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,GACxC,UAAU,SAAS,EAAE,EACrB,kBAAiB,SAAS,EAAO,KAChC,SAAS,EAgBX,CA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,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"}
@@ -2,9 +2,9 @@ import { remarkHeading, remarkMdxMermaid, remarkSteps, remarkStructure, } from "
2
2
  import { defineConfig as defineFumadocsConfig, frontmatterSchema, metaSchema, } from "fumadocs-mdx/config";
3
3
  import lastModified from "fumadocs-mdx/plugins/last-modified";
4
4
  import { z } from "zod";
5
- import { rehypeCodeHighlights } from "../rehype-code-highlights.js";
6
5
  import { rehypeTaskListLabels } from "../rehype-task-list-labels.js";
7
6
  import { remarkDetails } from "../remark-details.js";
7
+ import { searchIndex } from "../search-index.js";
8
8
  import { getLastModified } from "./internal/last-modified.js";
9
9
  const pluginOf = (entry) => Array.isArray(entry) ? entry[0] : entry;
10
10
  const indexOfPlugin = (list, plugin) => list.findIndex((entry) => pluginOf(entry) === plugin);
@@ -170,42 +170,33 @@ export const geistdocsMetaSchema = metaSchema;
170
170
  * Fumadocs, which places it among its defaults; a function receives those
171
171
  * defaults and returns the final list.
172
172
  */
173
- export const resolveGeistdocsRehypePlugins = (consumerPlugins, leadingPlugins = []) => {
173
+ export const resolveGeistdocsRehypePlugins = (consumerPlugins) => {
174
174
  if (typeof consumerPlugins === "function") {
175
- return (defaults) => [
176
- ...leadingPlugins,
177
- ...consumerPlugins(defaults),
178
- rehypeTaskListLabels,
179
- ];
175
+ return (defaults) => [...consumerPlugins(defaults), rehypeTaskListLabels];
180
176
  }
181
- return [...leadingPlugins, ...(consumerPlugins ?? []), rehypeTaskListLabels];
177
+ return [...(consumerPlugins ?? []), rehypeTaskListLabels];
182
178
  };
183
179
  export const defineGeistdocsSourceConfig = (config = {}) => {
184
180
  const existingRemarkPlugins = Array.isArray(config.mdxOptions?.remarkPlugins)
185
181
  ? config.mdxOptions.remarkPlugins
186
182
  : [];
187
183
  const existingPlugins = Array.isArray(config.plugins) ? config.plugins : [];
188
- const { highlighter = "highlights", ...fumadocsConfig } = config;
189
- const rehypeCodeOptions = {
190
- ...config.mdxOptions?.rehypeCodeOptions,
191
- themes: { light: geistShikiTheme },
192
- defaultColor: "light",
193
- };
194
- // `highlights` swaps Shiki's tokenizer for @pierre/highlights; `shiki`
195
- // keeps Fumadocs' rehypeCode.
196
- const highlightingDisabled = highlighter === false || config.mdxOptions?.rehypeCodeOptions === false;
197
- const useHighlights = highlighter === "highlights" && !highlightingDisabled;
198
184
  return defineFumadocsConfig({
199
- ...fumadocsConfig,
185
+ ...config,
200
186
  mdxOptions: {
201
187
  ...config.mdxOptions,
202
188
  remarkPlugins: (defaults) => resolveGeistdocsRemarkPlugins(defaults, existingRemarkPlugins),
203
- rehypePlugins: resolveGeistdocsRehypePlugins(config.mdxOptions?.rehypePlugins, useHighlights ? [[rehypeCodeHighlights, rehypeCodeOptions]] : []),
204
- rehypeCodeOptions: useHighlights || highlightingDisabled ? false : rehypeCodeOptions,
189
+ rehypePlugins: resolveGeistdocsRehypePlugins(config.mdxOptions?.rehypePlugins),
190
+ rehypeCodeOptions: {
191
+ ...config.mdxOptions?.rehypeCodeOptions,
192
+ themes: { light: geistShikiTheme },
193
+ defaultColor: "light",
194
+ },
205
195
  },
206
196
  plugins: [
207
197
  lastModified({ versionControl: getLastModified }),
208
198
  ...existingPlugins,
199
+ ...(config.searchIndex ? [searchIndex()] : []),
209
200
  ],
210
201
  });
211
202
  };
package/dist/source.d.ts CHANGED
@@ -1,11 +1,13 @@
1
- import type { InferPageType } from "fumadocs-core/source";
1
+ import { type InferPageType, loader } from "fumadocs-core/source";
2
2
  import type { PluggableList } from "unified";
3
- import { type GeistdocsPageSurface } from "./config.js";
3
+ import { type GeistdocsConfig, type GeistdocsPageSurface } from "./config.js";
4
4
  import { type MarkdownComponentElement, type MarkdownComponentSerializer, type MarkdownPropValue } from "./internal/mdx-to-markdown.js";
5
- import { type CreateNavigationOptions } from "./internal/source-loader.js";
6
5
  import { type GeistdocsVersionPaths } from "./internal/version-paths.js";
7
- export type { FumadocsCollection, GeistdocsSlugsContext, } from "./internal/source-loader.js";
8
6
  export type { GeistdocsVersionPaths } from "./internal/version-paths.js";
7
+ type LoaderOptions = Parameters<typeof loader>[0];
8
+ export interface FumadocsCollection {
9
+ toFumadocsSource(): LoaderOptions["source"];
10
+ }
9
11
  export interface GeistdocsSourcePageData {
10
12
  badge?: string;
11
13
  canonical?: string;
@@ -60,7 +62,16 @@ export interface GeistdocsMarkdownOptions {
60
62
  remarkPlugins?: PluggableList;
61
63
  transform?: (markdown: string, context: GeistdocsMarkdownContext) => Promise<string> | string;
62
64
  }
63
- export interface CreateSourceOptions extends CreateNavigationOptions {
65
+ export interface GeistdocsSlugsContext {
66
+ /** Content file path relative to the content directory, including any language suffix, such as `errors/NOT_FOUND.mdx` or `guide.cn.mdx`. */
67
+ path: string;
68
+ /** Default slugs derived from the path, without folder groups or a trailing `index`. */
69
+ slugs: string[];
70
+ }
71
+ export interface CreateSourceOptions {
72
+ baseUrl?: string;
73
+ config: Pick<GeistdocsConfig, "agent" | "basePath" | "defaultLanguage" | "singleLanguage" | "siteUrl" | "translations"> & Partial<Pick<GeistdocsConfig, "title">>;
74
+ docs: FumadocsCollection;
64
75
  id?: string;
65
76
  label?: string;
66
77
  markdown?: GeistdocsMarkdownOptions;
@@ -69,7 +80,7 @@ export interface CreateSourceOptions extends CreateNavigationOptions {
69
80
  * slugs apply everywhere page URLs appear: routes, the page tree, Markdown
70
81
  * routes, the sitemap, and `llms.txt`. Two pages may not share a URL.
71
82
  */
72
- slugs?: CreateNavigationOptions["slugs"];
83
+ slugs?: (context: GeistdocsSlugsContext) => string[];
73
84
  }
74
85
  export interface GeistdocsSourceDefinition extends Omit<CreateSourceOptions, "config"> {
75
86
  id: string;
@@ -1 +1 @@
1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,EAAE,KAAK,CAAC,CAAC;CAClE;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,iCAIvC,gCAAgC,KAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAiBvE,CAAC"}
package/dist/source.js CHANGED
@@ -1,6 +1,7 @@
1
+ import { defineI18n } from "fumadocs-core/i18n";
2
+ import { loader, } from "fumadocs-core/source";
1
3
  import { getPublicPath, withBasePath, } from "./config.js";
2
4
  import { createMdxToMarkdown, } from "./internal/mdx-to-markdown.js";
3
- import { createSourceLoader, } from "./internal/source-loader.js";
4
5
  import { stripVersionRoutePrefix, } from "./internal/version-paths.js";
5
6
  const MARKDOWN_LINK_PATTERN = /(\]\()(\/(?!\/)[^)\s]*)/g;
6
7
  const ROOT_ATTRIBUTE_PATTERN = /(\b(?:href|src)=["'])(\/(?!\/)[^"']*)/g;
@@ -56,6 +57,45 @@ const prefixMarkdownLinks = (markdown, basePath) => {
56
57
  ...prefixContentLinks(lines.slice(frontmatterEnd + 1), basePath),
57
58
  ].join("\n");
58
59
  };
60
+ const createSlugsPlugin = (transform) => {
61
+ // Each locale's storage inherits fallback pages from the default locale by
62
+ // reference, so transform every page object once.
63
+ const transformed = new WeakSet();
64
+ return {
65
+ name: "geistdocs:slugs",
66
+ // Runs after Fumadocs assigns the default slugs, so `index` pages and
67
+ // folder groups resolve before the transform sees them.
68
+ enforce: "post",
69
+ transformStorage({ storage }) {
70
+ const pathsByUrl = new Map();
71
+ for (const key of storage.getFiles()) {
72
+ const file = storage.read(key);
73
+ if (file?.format !== "page") {
74
+ continue;
75
+ }
76
+ if (!transformed.has(file)) {
77
+ // Storage keys drop the locale; `file.path` is the content file path.
78
+ file.slugs = transform({ path: file.path, slugs: [...file.slugs] });
79
+ transformed.add(file);
80
+ }
81
+ const url = file.slugs.join("/");
82
+ const existing = pathsByUrl.get(url);
83
+ if (existing) {
84
+ throw new Error(`Geistdocs slugs: ${existing} and ${file.path} both resolve to "/${url}".`);
85
+ }
86
+ pathsByUrl.set(url, file.path);
87
+ }
88
+ },
89
+ };
90
+ };
91
+ const getLanguages = (config) => {
92
+ const defaultLanguage = config.defaultLanguage ?? "en";
93
+ const languages = Object.keys(config.translations ?? {});
94
+ return {
95
+ defaultLanguage,
96
+ languages: Array.from(new Set([defaultLanguage, ...languages])),
97
+ };
98
+ };
59
99
  const YAML_NEEDS_QUOTING = /[:#{}[\]&*!|>'"%@`]/;
60
100
  const ALWAYS_QUOTED_FRONTMATTER = new Set(["badge", "navTitle"]);
61
101
  const formatFrontmatterValue = (value, forceQuotes = false) => {
@@ -90,8 +130,41 @@ const formatFrontmatter = (fields) => {
90
130
  lines.push("---");
91
131
  return lines.join("\n");
92
132
  };
133
+ const pageTreeTransformer = {
134
+ file(node, filePath) {
135
+ if (!filePath) {
136
+ return node;
137
+ }
138
+ const file = this.storage.read(filePath);
139
+ if (file?.format !== "page") {
140
+ return node;
141
+ }
142
+ const { badge, navTitle } = file.data;
143
+ return {
144
+ ...node,
145
+ ...(typeof badge === "string" && badge.length > 0 ? { badge } : {}),
146
+ ...(typeof navTitle === "string" && navTitle.length > 0
147
+ ? { name: navTitle }
148
+ : {}),
149
+ };
150
+ },
151
+ };
93
152
  export const createSource = ({ docs, config, baseUrl = "/docs", id, label, markdown, slugs, }) => {
94
- const source = createSourceLoader({ docs, config, baseUrl, slugs });
153
+ const { defaultLanguage, languages } = getLanguages(config);
154
+ const i18n = defineI18n({
155
+ defaultLanguage,
156
+ languages,
157
+ hideLocale: "default-locale",
158
+ });
159
+ const source = loader({
160
+ i18n,
161
+ baseUrl,
162
+ pageTree: {
163
+ transformers: [pageTreeTransformer],
164
+ },
165
+ plugins: slugs ? [createSlugsPlugin(slugs)] : undefined,
166
+ source: docs.toFumadocsSource(),
167
+ });
95
168
  const getPageImage = (page) => {
96
169
  const segments = [...page.slugs, "image.png"];
97
170
  return {
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.15.4-canary.2a54b38 so agents can understand the installed package without web access.
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.15.4-canary.2a54b38.
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. Brand selection is independent of `navbarVariant`, which selects the `"oss"` (default) or `"vercel"` layout; either supports both brands. The previous `"standard"` value remains supported as an alias for `"vercel"`. The OSS layout keeps your project's `Logo` and `logoHref` separate from the brand. The Vercel layout shows only the selected brand mark, with no separator, project logo, or OSS products menu.
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,32 +1424,88 @@ export const docs = defineDocs({
1424
1424
  export default defineGeistdocsSourceConfig();
1425
1425
  ```
1426
1426
 
1427
- ### MDX compiler
1427
+ ### Search-only collections
1428
1428
 
1429
- `createGeistdocs()` uses the native Rust MDX compiler by default with both Turbopack and webpack. Compatible pages compile natively; custom plugins, Shiki, unsupported content and platforms without a native binary use the JS pipeline automatically. Build output reports fallback reasons.
1429
+ Enable generation of search data without compiled page bodies:
1430
1430
 
1431
- Select a compiler in `next.config.ts`:
1431
+ ```ts title="source.config.ts"
1432
+ export default defineGeistdocsSourceConfig({ searchIndex: true });
1433
+ ```
1432
1434
 
1433
- ```ts
1434
- const withGeistdocs = createGeistdocs({ mdxCompiler: "auto" });
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
+ });
1435
1472
  ```
1436
1473
 
1437
- - `"auto"` (default): native when compatible, JS otherwise.
1438
- - `"native"`: fail if a page needs JS fallback; useful for checking native coverage.
1439
- - `"js"`: use the existing JS compiler for every page.
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.
1440
1479
 
1441
- Frontmatter-only requests do not compile page bodies. Native binaries ship with Geistdocs for macOS arm64 and Linux x64 (glibc 2.31+); consumers do not install Rust or a separate compiler package. Unsupported native content currently includes npm fences, Markdown images, includes, explicit code-tab wrappers and math. Actual native compiler errors fail the build instead of silently switching compilers.
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.
1442
1490
 
1443
- ### Code highlighter
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.
1444
1496
 
1445
- For a custom highlighter, pass `highlighter: false` to `defineGeistdocsSourceConfig`; the native compiler will fall back to JS so your plugins run. Passing `mdxOptions.rehypeCodeOptions: false` to the helper also disables built-in highlighting.
1497
+ ### Code highlighter (public package)
1446
1498
 
1447
- Code blocks are tokenized by [Highlights](https://diffs.com/highlights), which uses hand-written WebAssembly lexers, and rendered with the same HTML as Shiki: Geist colors, titles, icons, tabs, and `[!code ...]` notation all work. Languages without a built-in Highlights lexer render as plain text. To use Shiki's TextMate grammars instead, for example for an unsupported language, pass `highlighter: "shiki"`:
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"`:
1448
1500
 
1449
1501
  ```ts title="source.config.ts"
1450
1502
  export default defineGeistdocsSourceConfig({ highlighter: "shiki" });
1451
1503
  ```
1452
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
+
1453
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.
1454
1510
 
1455
1511
  ## Page URLs
@@ -467,5 +467,5 @@
467
467
  }
468
468
  ],
469
469
  "source": "apps/template/content/docs",
470
- "version": "2.15.4-canary.2a54b38"
470
+ "version": "2.16.0-canary.abbda54"
471
471
  }