@vercel/geistdocs 2.15.2 → 2.15.3-canary.7d55dcf

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 (64) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/internal/mdx-to-markdown.d.ts.map +1 -1
  3. package/dist/internal/mdx-to-markdown.js +9 -0
  4. package/dist/internal/page-actions.d.ts +4 -4
  5. package/dist/internal/page-actions.d.ts.map +1 -1
  6. package/dist/internal/page-actions.js +6 -1
  7. package/dist/internal/source-loader.d.ts +28 -0
  8. package/dist/internal/source-loader.d.ts.map +1 -0
  9. package/dist/internal/source-loader.js +77 -0
  10. package/dist/mdx-basic.d.ts +27 -0
  11. package/dist/mdx-basic.d.ts.map +1 -0
  12. package/dist/mdx-basic.js +61 -0
  13. package/dist/mdx.d.ts +3 -25
  14. package/dist/mdx.d.ts.map +1 -1
  15. package/dist/mdx.js +8 -61
  16. package/dist/navigation.d.ts +11 -0
  17. package/dist/navigation.d.ts.map +1 -0
  18. package/dist/navigation.js +8 -0
  19. package/dist/next.d.ts +9 -1
  20. package/dist/next.d.ts.map +1 -1
  21. package/dist/next.js +25 -2
  22. package/dist/pages/docs-custom.d.ts +111 -0
  23. package/dist/pages/docs-custom.d.ts.map +1 -0
  24. package/dist/pages/docs-custom.js +250 -0
  25. package/dist/pages/docs.d.ts +5 -98
  26. package/dist/pages/docs.d.ts.map +1 -1
  27. package/dist/pages/docs.js +13 -250
  28. package/dist/source-config.d.ts +10 -1
  29. package/dist/source-config.d.ts.map +1 -1
  30. package/dist/source-config.js +20 -10
  31. package/dist/source.d.ts +6 -17
  32. package/dist/source.d.ts.map +1 -1
  33. package/dist/source.js +2 -75
  34. package/docs/agents.md +1 -1
  35. package/docs/llms.txt +9 -1
  36. package/docs/manifest.json +1 -1
  37. package/docs/pages/configuration.md +8 -0
  38. package/native-mdx/LICENSE-mdxjs-rs +22 -0
  39. package/native-mdx/binaries/darwin-arm64.node +0 -0
  40. package/native-mdx/binaries/linux-x64-gnu.node +0 -0
  41. package/native-mdx/data-entry.d.mts +15 -0
  42. package/native-mdx/data-entry.mjs +97 -0
  43. package/native-mdx/data-projection.mjs +205 -0
  44. package/native-mdx/index-emitter.mjs +34 -0
  45. package/native-mdx/loader-data.cjs +36 -0
  46. package/native-mdx/loader-mdx.cjs +9 -0
  47. package/native-mdx/loader-mdx.mjs +262 -0
  48. package/native-mdx/native-binding.cjs +25 -0
  49. package/native-mdx/navigation-entry.d.mts +11 -0
  50. package/native-mdx/navigation-entry.mjs +136 -0
  51. package/native-mdx/navigation-title.mjs +53 -0
  52. package/package.json +36 -8
  53. package/rehype-code-highlights.d.ts +13 -0
  54. package/rehype-code-highlights.js +230 -0
  55. package/source-config.js +24 -10
  56. package/template/app/[lang]/(home)/opengraph-image.tsx +4 -28
  57. package/template/app/[lang]/og/[...slug]/route.tsx +5 -68
  58. package/template/content/docs/configuration.mdx +8 -0
  59. package/template/lib/geistdocs/geist-mono-regular.ttf +0 -0
  60. package/template/lib/geistdocs/og.tsx +95 -0
  61. package/template/package.json +1 -1
  62. package/template/app/[lang]/og/[...slug]/background.png +0 -0
  63. package/template/app/[lang]/og/[...slug]/geist-sans-semibold.ttf +0 -0
  64. /package/template/{app/[lang]/og/[...slug] → lib/geistdocs}/geist-sans-regular.ttf +0 -0
@@ -1,251 +1,14 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import Link from "fumadocs-core/link";
3
- import { DocsBody as FumadocsDocsBody, DocsPage as FumadocsDocsPage, DocsTitle as FumadocsDocsTitle, } from "fumadocs-ui/layouts/docs/page";
4
- import { notFound } from "next/navigation";
5
- import { cache, } from "react";
6
- import { cn } from "#geistdocs-ui/utils";
7
- import { NativeDocsLink } from "../components/link";
8
- import { getPublicPath, withBasePath } from "../config";
9
- import { getDocsLinkClassName } from "../internal/docs-link-class-name";
10
- import { DocsPageErrorBoundary } from "../internal/docs-page-error-boundary";
11
- import { resolveDocumentTitle } from "../internal/document-title";
12
- import { omitLanguageParam, resolveRouteLanguage } from "../internal/languages";
13
- import { resolveLinkHref, stripBasePathFromHref } from "../internal/link-href";
14
- import { resolvePageMarkdownUrl as resolveInternalPageMarkdownUrl } from "../internal/markdown-url.js";
15
- import { createPageActions as createInternalPageActions } from "../internal/page-actions";
16
- import { GeistdocsPageActions } from "../internal/page-actions-gate";
17
- import { PageBreadcrumb } from "../internal/page-breadcrumb";
18
- import { getPageFooterItems, PageFooter } from "../internal/page-footer";
19
- import { filterPageTree } from "../internal/page-tree-visibility";
20
- import { createRelativeDocsLink } from "../internal/relative-docs-link";
21
- import { GeistdocsTableOfContents } from "../internal/table-of-contents";
22
- import { GeistdocsTableOfContentsActions } from "../internal/toc-actions-client";
23
1
  import { createMdxComponents } from "../mdx";
24
- import { getPageRobots, } from "../page-visibility";
25
- const renderPrefetchedDocsLink = (siteUrl, basePath, { children, className, href, rel, target, ...props }) => {
26
- const originalHref = String(href ?? "");
27
- const resolved = resolveLinkHref(originalHref, siteUrl);
28
- const linkHref = resolved.href === originalHref
29
- ? resolved.href
30
- : stripBasePathFromHref(resolved.href, basePath);
31
- return (_jsx(Link, { ...props, className: getDocsLinkClassName(className), href: linkHref, prefetch: !resolved.external, rel: resolved.external ? rel : undefined, target: resolved.external ? target : undefined, children: children }));
32
- };
33
- export const resolvePageMarkdownUrl = (options) => resolveInternalPageMarkdownUrl(options);
34
- /**
35
- * The page's visible article parts carry `data-geistdocs-article` (`title`,
36
- * `body`) so tools that read the rendered HTML (docs
37
- * crawlers, parity checks against the Markdown route) can select the
38
- * article without depending on Fumadocs' element ids or on class names.
39
- * The marked elements hold content only: page actions, breadcrumbs, the
40
- * table of contents, and the previous/next footer sit outside them.
41
- */
42
- const DocsTitle = ({ className, ...props }) => (_jsx(FumadocsDocsTitle, { className: cn("mb-4 text-balance", className), "data-geistdocs-article": "title", ...props }));
43
- const DocsBody = ({ className, ...props }) => (_jsx(FumadocsDocsBody, { className: cn("mx-auto w-full", className), "data-geistdocs-article": "body", ...props }));
44
- /** App-provided footer content below the table-of-contents actions. */
45
- const TocFooterSlot = ({ children }) => children ? _jsx("div", { className: "mt-4", children: children }) : null;
46
- const hasTableOfContentsActions = (config, extraActions) => config.pageActions?.scrollTop !== false ||
47
- config.feedback?.enabled !== false ||
48
- extraActions.length > 0;
49
- const serializeParams = (params) => JSON.stringify(Object.entries(params)
50
- .filter(([, value]) => value !== undefined)
51
- .sort(([left], [right]) => left.localeCompare(right)));
52
- export const createDocsPage = ({ canViewPage, config, source, mdx, pageActions = createInternalPageActions({ config }), filterStaticParams, getMarkdownUrl, getPageUrl, getPublicPageUrl, metadata, openGraph, renderTop, resolveLink, tableOfContent, tableOfContentPopover, }) => {
53
- const DocsLink = renderPrefetchedDocsLink.bind(null, config.siteUrl, config.basePath);
54
- const resolvePageUrls = (page, params) => {
55
- const pageUrl = getPageUrl?.({ page, params }) ?? page.url;
56
- const publicPageUrl = getPublicPageUrl?.({ page, params, pageUrl }) ??
57
- getPublicPath(pageUrl, config.basePath);
58
- const markdownUrl = getMarkdownUrl?.({ page, params, pageUrl, publicPageUrl }) ??
59
- resolveInternalPageMarkdownUrl({
60
- basePath: config.basePath,
61
- isRootMountedPage: source.baseUrl === "/" && page.slugs.length === 0,
62
- pageUrl,
63
- publicPageUrl,
64
- });
65
- return { markdownUrl, pageUrl, publicPageUrl };
66
- };
67
- const getAccessState = cache(async (paramsKey) => {
68
- const params = Object.fromEntries(JSON.parse(paramsKey));
69
- const tree = source.source.getPageTree(params.lang);
70
- if (!canViewPage) {
71
- return { tree, visibleUrls: undefined };
72
- }
73
- const access = await Promise.all(source.source.getPages(params.lang).map(async (page) => ({
74
- page,
75
- visible: await canViewPage(page, { params, source }),
76
- })));
77
- const visibleUrls = new Set(access.filter(({ visible }) => visible).map(({ page }) => page.url));
78
- const hiddenUrls = new Set(access.filter(({ visible }) => !visible).map(({ page }) => page.url));
79
- return { tree: filterPageTree(tree, hiddenUrls), visibleUrls };
80
- });
81
- // Single-language apps have no [lang] segment, so params arrive without it.
82
- const resolveParams = async (params) => {
83
- const resolved = await params;
84
- return {
85
- ...resolved,
86
- lang: resolveRouteLanguage(config, resolved.lang),
87
- };
88
- };
89
- const getPage = async (params) => {
90
- const page = source.source.getPage(params.slug, params.lang);
91
- if (!page) {
92
- notFound();
93
- }
94
- if (canViewPage) {
95
- const { visibleUrls } = await getAccessState(serializeParams(params));
96
- if (!visibleUrls?.has(page.url)) {
97
- notFound();
98
- }
99
- }
100
- return page;
101
- };
102
- const getPageTree = async (params) => (await getAccessState(serializeParams(params))).tree;
103
- const PageContent = async ({ params }) => {
104
- const resolvedParams = await resolveParams(params);
105
- const { lang } = resolvedParams;
106
- const page = await getPage(resolvedParams);
107
- const pageTree = await getPageTree(resolvedParams);
108
- const data = page.data;
109
- const MDX = data.body;
110
- const defaultLink = createRelativeDocsLink(source.source, page, DocsLink);
111
- const link = resolveLink
112
- ? resolveLink({
113
- link: defaultLink,
114
- nativeLink: NativeDocsLink,
115
- page,
116
- source,
117
- })
118
- : defaultLink;
119
- const resolvedMdx = typeof mdx === "function" ? mdx({ link, page, source }) : mdx;
120
- const { markdownUrl, pageUrl, publicPageUrl } = resolvePageUrls(page, resolvedParams);
121
- const footerItems = getPageFooterItems(pageTree, page.url);
122
- const pagesByUrl = getPageUrl
123
- ? new Map(source.source.getPages(lang).map((entry) => [entry.url, entry]))
124
- : undefined;
125
- const resolveFooterItem = (item) => {
126
- if (!(item && getPageUrl && pagesByUrl)) {
127
- return item;
128
- }
129
- const itemPage = pagesByUrl.get(item.url);
130
- if (!itemPage) {
131
- return item;
132
- }
133
- return {
134
- ...item,
135
- url: getPageUrl({
136
- page: itemPage,
137
- params: { ...resolvedParams, slug: itemPage.slugs },
138
- }),
139
- };
140
- };
141
- const resolvedFooterItems = {
142
- previous: resolveFooterItem(footerItems.previous),
143
- next: resolveFooterItem(footerItems.next),
144
- };
145
- const markdown = pageActions.getExtraActions || renderTop
146
- ? await source.getPageMarkdown(page)
147
- : undefined;
148
- const footerActions = markdown
149
- ? (pageActions.getExtraActions?.({
150
- markdown,
151
- page: {
152
- path: page.path,
153
- url: publicPageUrl,
154
- },
155
- }) ?? [])
156
- : [];
157
- const hasTocActions = hasTableOfContentsActions(pageActions.config, footerActions);
158
- const hasTocLinks = Boolean(data.toc?.length);
159
- // Actions stay adjacent to the table of contents; the app-provided
160
- // footer (promos and other custom content) renders below them.
161
- const tocFooter = (_jsxs(_Fragment, { children: [hasTocLinks && hasTocActions ? (_jsx("div", { className: "mt-4 border-gray-alpha-400 border-t pt-4", children: _jsx("nav", { "aria-label": "Page actions", className: "flex min-w-0 flex-col gap-1", children: _jsx(GeistdocsTableOfContentsActions, { config: pageActions.config, extraActions: footerActions }) }) })) : null, _jsx(TocFooterSlot, { children: tableOfContent?.footer })] }));
162
- const tocComponent = tableOfContent?.component ?? (_jsx(GeistdocsTableOfContents, { footer: tocFooter, header: tableOfContent?.header, toc: data.toc ?? [] }));
163
- return (_jsxs(FumadocsDocsPage, { breadcrumb: {
164
- component: _jsx(PageBreadcrumb, { tree: pageTree, url: page.url }),
165
- }, footer: { component: _jsx(PageFooter, { ...resolvedFooterItems }) }, full: data.full, tableOfContent: {
166
- enabled: true,
167
- single: true,
168
- ...tableOfContent,
169
- component: tocComponent,
170
- }, tableOfContentPopover: {
171
- enabled: false,
172
- ...tableOfContentPopover,
173
- }, toc: data.toc, children: [renderTop?.({
174
- data,
175
- markdown: markdown ?? "",
176
- markdownUrl,
177
- page,
178
- pageUrl,
179
- publicPageUrl,
180
- }), _jsxs("div", { className: "mb-8 flex flex-col-reverse gap-4 md:flex-row md:items-end md:justify-between", children: [_jsx(DocsTitle, { className: "mb-0 min-w-0", children: data.title }), _jsx(GeistdocsPageActions, { config: pageActions.config, only: "desktop", page: {
181
- markdownUrl,
182
- path: page.path,
183
- title: data.title,
184
- url: publicPageUrl,
185
- } })] }), _jsx("div", { className: "-mt-6 mb-4 @min-[961px]:hidden", children: _jsx(GeistdocsPageActions, { config: pageActions.config, only: "mobile", page: {
186
- markdownUrl,
187
- path: page.path,
188
- title: data.title,
189
- url: publicPageUrl,
190
- } }) }), _jsx(DocsBody, { children: _jsx(MDX, { components: {
191
- ...createMdxComponents({ a: link }),
192
- ...resolvedMdx,
193
- } }) })] }));
194
- };
195
- const Page = ({ params }) => (_jsx(DocsPageErrorBoundary, { children: _jsx(PageContent, { params: params }) }));
196
- const generateStaticParams = () => {
197
- const params = source.source.generateParams();
198
- const filtered = filterStaticParams
199
- ? params.filter(filterStaticParams)
200
- : params;
201
- return omitLanguageParam(config, filtered);
202
- };
203
- const generateMetadata = async ({ params, }) => {
204
- const resolvedParams = await resolveParams(params);
205
- const page = await getPage(resolvedParams);
206
- const pageTree = await getPageTree(resolvedParams);
207
- const data = page.data;
208
- const { markdownUrl, publicPageUrl } = resolvePageUrls(page, resolvedParams);
209
- const openGraphImages = openGraph?.images === true
210
- ? source.getPageImage(page).url
211
- : openGraph?.images;
212
- let canonicalUrl;
213
- if (data.canonical) {
214
- canonicalUrl = withBasePath(data.canonical, config.basePath);
215
- }
216
- else if (config.siteUrl) {
217
- canonicalUrl = new URL(publicPageUrl, config.siteUrl).toString();
218
- }
219
- const defaultMetadata = {
220
- title: resolveDocumentTitle({
221
- pageTitle: data.title,
222
- pageUrl: page.url,
223
- tree: pageTree,
224
- }),
225
- description: data.description,
226
- keywords: data.keywords,
227
- robots: getPageRobots(page),
228
- ...(openGraphImages ? { openGraph: { images: openGraphImages } } : {}),
229
- alternates: {
230
- canonical: canonicalUrl,
231
- types: {
232
- "text/markdown": markdownUrl,
233
- },
234
- },
235
- };
236
- return metadata
237
- ? await metadata({
238
- metadata: defaultMetadata,
239
- page,
240
- params: resolvedParams,
241
- })
242
- : defaultMetadata;
243
- };
244
- return {
245
- Page,
246
- getPageTree,
247
- generateStaticParams,
248
- generateMetadata,
249
- };
250
- };
251
- export const createPageActions = createInternalPageActions;
2
+ import { createDocsPage as createCustomDocsPage, } from "./docs-custom";
3
+ // biome-ignore lint/performance/noBarrelFile: Keep the existing public API while the custom entry avoids the default registry.
4
+ export { createPageActions, resolvePageMarkdownUrl, } from "./docs-custom";
5
+ /** The default factory keeps the complete Geistdocs MDX component registry. */
6
+ export const createDocsPage = (options) => createCustomDocsPage({
7
+ ...options,
8
+ mdx: (context) => ({
9
+ ...createMdxComponents({ a: context.link }),
10
+ ...(typeof options.mdx === "function"
11
+ ? options.mdx(context)
12
+ : options.mdx),
13
+ }),
14
+ });
@@ -3,6 +3,15 @@ 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.
11
+ *
12
+ * @defaultValue "highlights"
13
+ */
14
+ highlighter?: "shiki" | "highlights";
6
15
  mdxOptions?: DefaultMDXOptions;
7
16
  plugins?: FumadocsConfigInput["plugins"];
8
17
  }
@@ -81,7 +90,7 @@ export declare const geistdocsMetaSchema: z.ZodObject<{
81
90
  * Fumadocs, which places it among its defaults; a function receives those
82
91
  * defaults and returns the final list.
83
92
  */
84
- export declare const resolveGeistdocsRehypePlugins: (consumerPlugins: DefaultMDXOptions["rehypePlugins"]) => NonNullable<DefaultMDXOptions["rehypePlugins"]>;
93
+ export declare const resolveGeistdocsRehypePlugins: (consumerPlugins: DefaultMDXOptions["rehypePlugins"], leadingPlugins?: Pluggable[]) => NonNullable<DefaultMDXOptions["rehypePlugins"]>;
85
94
  export declare const defineGeistdocsSourceConfig: (config?: GeistdocsSourceConfigOptions) => import("fumadocs-mdx/config").GlobalConfig;
86
95
  export {};
87
96
  //# 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;AAKxB,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;CAC1C;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,+CA2B1C,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;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IACrC,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,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,EACnD,iBAAgB,SAAS,EAAO,KAC/B,WAAW,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAShD,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,SAAQ,4BAAiC,+CAiC1C,CAAC"}
@@ -2,6 +2,7 @@ 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";
5
6
  import { rehypeTaskListLabels } from "../rehype-task-list-labels.js";
6
7
  import { remarkDetails } from "../remark-details.js";
7
8
  import { getLastModified } from "./internal/last-modified.js";
@@ -169,28 +170,37 @@ export const geistdocsMetaSchema = metaSchema;
169
170
  * Fumadocs, which places it among its defaults; a function receives those
170
171
  * defaults and returns the final list.
171
172
  */
172
- export const resolveGeistdocsRehypePlugins = (consumerPlugins) => {
173
+ export const resolveGeistdocsRehypePlugins = (consumerPlugins, leadingPlugins = []) => {
173
174
  if (typeof consumerPlugins === "function") {
174
- return (defaults) => [...consumerPlugins(defaults), rehypeTaskListLabels];
175
+ return (defaults) => [
176
+ ...leadingPlugins,
177
+ ...consumerPlugins(defaults),
178
+ rehypeTaskListLabels,
179
+ ];
175
180
  }
176
- return [...(consumerPlugins ?? []), rehypeTaskListLabels];
181
+ return [...leadingPlugins, ...(consumerPlugins ?? []), rehypeTaskListLabels];
177
182
  };
178
183
  export const defineGeistdocsSourceConfig = (config = {}) => {
179
184
  const existingRemarkPlugins = Array.isArray(config.mdxOptions?.remarkPlugins)
180
185
  ? config.mdxOptions.remarkPlugins
181
186
  : [];
182
187
  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 useHighlights = highlighter === "highlights";
183
197
  return defineFumadocsConfig({
184
- ...config,
198
+ ...fumadocsConfig,
185
199
  mdxOptions: {
186
200
  ...config.mdxOptions,
187
201
  remarkPlugins: (defaults) => resolveGeistdocsRemarkPlugins(defaults, existingRemarkPlugins),
188
- rehypePlugins: resolveGeistdocsRehypePlugins(config.mdxOptions?.rehypePlugins),
189
- rehypeCodeOptions: {
190
- ...config.mdxOptions?.rehypeCodeOptions,
191
- themes: { light: geistShikiTheme },
192
- defaultColor: "light",
193
- },
202
+ rehypePlugins: resolveGeistdocsRehypePlugins(config.mdxOptions?.rehypePlugins, useHighlights ? [[rehypeCodeHighlights, rehypeCodeOptions]] : []),
203
+ rehypeCodeOptions: useHighlights ? false : rehypeCodeOptions,
194
204
  },
195
205
  plugins: [
196
206
  lastModified({ versionControl: getLastModified }),
package/dist/source.d.ts CHANGED
@@ -1,13 +1,11 @@
1
- import { type InferPageType, loader } from "fumadocs-core/source";
1
+ import type { InferPageType } from "fumadocs-core/source";
2
2
  import type { PluggableList } from "unified";
3
- import { type GeistdocsConfig, type GeistdocsPageSurface } from "./config.js";
3
+ import { 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";
5
6
  import { type GeistdocsVersionPaths } from "./internal/version-paths.js";
7
+ export type { FumadocsCollection, GeistdocsSlugsContext, } from "./internal/source-loader.js";
6
8
  export type { GeistdocsVersionPaths } from "./internal/version-paths.js";
7
- type LoaderOptions = Parameters<typeof loader>[0];
8
- export interface FumadocsCollection {
9
- toFumadocsSource(): LoaderOptions["source"];
10
- }
11
9
  export interface GeistdocsSourcePageData {
12
10
  badge?: string;
13
11
  canonical?: string;
@@ -62,16 +60,7 @@ export interface GeistdocsMarkdownOptions {
62
60
  remarkPlugins?: PluggableList;
63
61
  transform?: (markdown: string, context: GeistdocsMarkdownContext) => Promise<string> | string;
64
62
  }
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;
63
+ export interface CreateSourceOptions extends CreateNavigationOptions {
75
64
  id?: string;
76
65
  label?: string;
77
66
  markdown?: GeistdocsMarkdownOptions;
@@ -80,7 +69,7 @@ export interface CreateSourceOptions {
80
69
  * slugs apply everywhere page URLs appear: routes, the page tree, Markdown
81
70
  * routes, the sitemap, and `llms.txt`. Two pages may not share a URL.
82
71
  */
83
- slugs?: (context: GeistdocsSlugsContext) => string[];
72
+ slugs?: CreateNavigationOptions["slugs"];
84
73
  }
85
74
  export interface GeistdocsSourceDefinition extends Omit<CreateSourceOptions, "config"> {
86
75
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAElB,MAAM,EAEP,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAG1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AA0FlD,MAAM,WAAW,kBAAkB;IACjC,gBAAgB,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,OA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BAAqB,GAAG,qBAAqB,EAAE,CAAC;CAC1D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,6CAKjC,0BAA0B,KAAG,MAAM,EAYrC,CAAC;AAEF,MAAM,WAAW,gCAAgC;IAC/C,UAAU,CAAC,EAAE,0BAA0B,CAAC,YAAY,CAAC,CAAC;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,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,7 +1,6 @@
1
- import { defineI18n } from "fumadocs-core/i18n";
2
- import { loader, } from "fumadocs-core/source";
3
1
  import { getPublicPath, withBasePath, } from "./config.js";
4
2
  import { createMdxToMarkdown, } from "./internal/mdx-to-markdown.js";
3
+ import { createSourceLoader, } from "./internal/source-loader.js";
5
4
  import { stripVersionRoutePrefix, } from "./internal/version-paths.js";
6
5
  const MARKDOWN_LINK_PATTERN = /(\]\()(\/(?!\/)[^)\s]*)/g;
7
6
  const ROOT_ATTRIBUTE_PATTERN = /(\b(?:href|src)=["'])(\/(?!\/)[^"']*)/g;
@@ -57,45 +56,6 @@ const prefixMarkdownLinks = (markdown, basePath) => {
57
56
  ...prefixContentLinks(lines.slice(frontmatterEnd + 1), basePath),
58
57
  ].join("\n");
59
58
  };
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
- };
99
59
  const YAML_NEEDS_QUOTING = /[:#{}[\]&*!|>'"%@`]/;
100
60
  const ALWAYS_QUOTED_FRONTMATTER = new Set(["badge", "navTitle"]);
101
61
  const formatFrontmatterValue = (value, forceQuotes = false) => {
@@ -130,41 +90,8 @@ const formatFrontmatter = (fields) => {
130
90
  lines.push("---");
131
91
  return lines.join("\n");
132
92
  };
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
- };
152
93
  export const createSource = ({ docs, config, baseUrl = "/docs", id, label, markdown, 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
- });
94
+ const source = createSourceLoader({ docs, config, baseUrl, slugs });
168
95
  const getPageImage = (page) => {
169
96
  const segments = [...page.slugs, "image.png"];
170
97
  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.2 so agents can understand the installed package without web access.
3
+ These docs are bundled with `@vercel/geistdocs` 2.15.3-canary.7d55dcf 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.2.
3
+ These docs are bundled with `@vercel/geistdocs` 2.15.3-canary.7d55dcf.
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
@@ -1424,6 +1424,14 @@ export const docs = defineDocs({
1424
1424
  export default defineGeistdocsSourceConfig();
1425
1425
  ```
1426
1426
 
1427
+ ### Code highlighter
1428
+
1429
+ 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"`:
1430
+
1431
+ ```ts title="source.config.ts"
1432
+ export default defineGeistdocsSourceConfig({ highlighter: "shiki" });
1433
+ ```
1434
+
1427
1435
  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
1436
 
1429
1437
  ## Page URLs
@@ -467,5 +467,5 @@
467
467
  }
468
468
  ],
469
469
  "source": "apps/template/content/docs",
470
- "version": "2.15.2"
470
+ "version": "2.15.3-canary.7d55dcf"
471
471
  }
@@ -285,6 +285,14 @@ export const docs = defineDocs({
285
285
  export default defineGeistdocsSourceConfig();
286
286
  ```
287
287
 
288
+ ### Code highlighter
289
+
290
+ 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"`:
291
+
292
+ ```ts title="source.config.ts"
293
+ export default defineGeistdocsSourceConfig({ highlighter: "shiki" });
294
+ ```
295
+
288
296
  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
297
 
290
298
  ## Page URLs
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2022 Titus Wormer <tituswormer@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,15 @@
1
+ import type { Plugin } from "fumadocs-mdx";
2
+ import type * as TypeScript from "typescript";
3
+
4
+ type Parser = typeof TypeScript;
5
+
6
+ /** Extend Fumadocs 14's existing emitter with an opt-in data.ts entry. */
7
+ export declare function dataEntryPlugin(
8
+ parser: Parser | (() => Parser | Promise<Parser>)
9
+ ): Plugin;
10
+
11
+ /** Derive an entry in the same directory as the generated server.ts. */
12
+ export declare function createDataEntry(
13
+ serverCode: string,
14
+ parser: Parser
15
+ ): { code: string; imports: number };