@vercel/geistdocs 2.15.3-canary.f771302 → 2.15.4

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 (47) 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 +0 -9
  4. package/dist/internal/page-actions-client.js +1 -1
  5. package/dist/internal/page-actions.d.ts +4 -4
  6. package/dist/internal/page-actions.d.ts.map +1 -1
  7. package/dist/internal/page-actions.js +1 -6
  8. package/dist/mdx.d.ts +25 -3
  9. package/dist/mdx.d.ts.map +1 -1
  10. package/dist/mdx.js +61 -8
  11. package/dist/mobile-docs-bar.js +1 -1
  12. package/dist/next.d.ts +1 -9
  13. package/dist/next.d.ts.map +1 -1
  14. package/dist/next.js +2 -25
  15. package/dist/pages/docs.d.ts +98 -5
  16. package/dist/pages/docs.d.ts.map +1 -1
  17. package/dist/pages/docs.js +250 -13
  18. package/dist/source-config.d.ts +1 -10
  19. package/dist/source-config.d.ts.map +1 -1
  20. package/dist/source-config.js +10 -20
  21. package/docs/agents.md +1 -1
  22. package/docs/llms.txt +1 -9
  23. package/docs/manifest.json +1 -1
  24. package/docs/pages/configuration.md +0 -8
  25. package/package.json +8 -28
  26. package/shared-theme.css +7 -1
  27. package/source-config.js +10 -24
  28. package/template/content/docs/configuration.mdx +0 -8
  29. package/template/package.json +1 -1
  30. package/dist/mdx-basic.d.ts +0 -27
  31. package/dist/mdx-basic.d.ts.map +0 -1
  32. package/dist/mdx-basic.js +0 -61
  33. package/dist/pages/docs-custom.d.ts +0 -111
  34. package/dist/pages/docs-custom.d.ts.map +0 -1
  35. package/dist/pages/docs-custom.js +0 -250
  36. package/native-mdx/LICENSE-mdxjs-rs +0 -22
  37. package/native-mdx/binaries/darwin-arm64.node +0 -0
  38. package/native-mdx/binaries/linux-x64-gnu.node +0 -0
  39. package/native-mdx/data-entry.d.mts +0 -15
  40. package/native-mdx/data-entry.mjs +0 -116
  41. package/native-mdx/data-projection.mjs +0 -205
  42. package/native-mdx/loader-data.cjs +0 -36
  43. package/native-mdx/loader-mdx.cjs +0 -9
  44. package/native-mdx/loader-mdx.mjs +0 -235
  45. package/native-mdx/native-binding.cjs +0 -25
  46. package/rehype-code-highlights.d.ts +0 -13
  47. package/rehype-code-highlights.js +0 -230
package/dist/mdx-basic.js DELETED
@@ -1,61 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Image as FrameworkImage } from "fumadocs-core/framework";
3
- import { Card, Cards } from "fumadocs-ui/components/card";
4
- import Link from "next/link";
5
- import { cn } from "#geistdocs-ui/utils";
6
- import { Blockquote } from "./components/blockquote";
7
- import { Button } from "./components/button";
8
- import { Callout, CalloutContainer, CalloutDescription, CalloutTitle, } from "./components/callout";
9
- import { CodeBlock } from "./components/code-block";
10
- import { Details, Summary } from "./components/details";
11
- import { Heading } from "./components/heading";
12
- import { Image } from "./components/image";
13
- import { Step, Steps } from "./components/steps";
14
- import { Table } from "./components/table";
15
- import { TypeTable } from "./components/type-table";
16
- import { LocalizedLink } from "./internal/localized-link";
17
- import { geistShikiTheme as shikiTheme } from "./shiki-theme";
18
- // The source-config exports live on @vercel/geistdocs/source-config. Importing
19
- // them here would pull fumadocs-mdx/config, and through it Shiki with every
20
- // language grammar, into every server function that renders MDX.
21
- export const geistShikiTheme = shikiTheme;
22
- export const getGeistdocsMDXComponents = (components) => ({
23
- Card,
24
- Cards,
25
- img: (props) => (_jsx(FrameworkImage, { sizes: "(max-width: 768px) 100vw, (max-width: 1200px) 70vw, 900px", ...props, className: cn("rounded-lg", props.className), src: props.src })),
26
- h1: (props) => _jsx(Heading, { as: "h1", ...props }),
27
- h2: (props) => _jsx(Heading, { as: "h2", ...props }),
28
- h3: (props) => _jsx(Heading, { as: "h3", ...props }),
29
- h4: (props) => _jsx(Heading, { as: "h4", ...props }),
30
- h5: (props) => _jsx(Heading, { as: "h5", ...props }),
31
- h6: (props) => _jsx(Heading, { as: "h6", ...props }),
32
- pre: CodeBlock,
33
- blockquote: Blockquote,
34
- table: Table,
35
- Table,
36
- a: ({ children, className, href, ...props }) => {
37
- const linkClassName = cn("font-normal text-gray-1000! underline decoration-1 decoration-gray-700 underline-offset-4 hover:text-gray-1000! hover:decoration-gray-1000 hover:opacity-100!", className);
38
- if (typeof href === "string" && href.startsWith("/")) {
39
- return (_jsx(LocalizedLink, { className: linkClassName, href: href, ...props, children: children }));
40
- }
41
- // next/link keeps same-page fragment entries restorable by the App Router.
42
- if (typeof href === "string" && href.startsWith("#")) {
43
- return (_jsx(Link, { className: linkClassName, href: href, prefetch: false, ...props, children: children }));
44
- }
45
- return (_jsx("a", { className: linkClassName, href: href, ...props, children: children }));
46
- },
47
- Button,
48
- TypeTable,
49
- Callout,
50
- CalloutContainer,
51
- CalloutTitle,
52
- CalloutDescription,
53
- Details,
54
- Summary,
55
- Image,
56
- Steps,
57
- Step,
58
- ...components,
59
- });
60
- export const createMdxComponents = (components) => getGeistdocsMDXComponents(components);
61
- export const mergeGeistdocsMDXComponents = (...componentSets) => Object.assign({}, ...componentSets.filter(Boolean));
@@ -1,111 +0,0 @@
1
- import { DocsPage as FumadocsDocsPage } from "fumadocs-ui/layouts/docs/page";
2
- import type { MDXComponents } from "mdx/types";
3
- import type { Metadata } from "next";
4
- import { type ComponentProps, type ComponentType, type ReactNode } from "react";
5
- import { NativeDocsLink } from "../components/link";
6
- import { type GeistdocsConfig } from "../config";
7
- import { type GeistdocsPageVisibilityData } from "../page-visibility";
8
- import type { GeistdocsSourceBundle } from "../source";
9
- type SourceBundle = GeistdocsSourceBundle;
10
- type GeistdocsPage = NonNullable<ReturnType<SourceBundle["source"]["getPage"]>>;
11
- type PageActionsBundle = ReturnType<typeof createPageActions>;
12
- type DocsPageLink = MDXComponents["a"];
13
- type TableOfContentOptions = NonNullable<ComponentProps<typeof FumadocsDocsPage>["tableOfContent"]>;
14
- export interface DocsPageParams extends Record<string, string | string[] | undefined> {
15
- lang: string;
16
- slug?: string[];
17
- }
18
- export interface DocsPageAccessContext<Params extends DocsPageParams = DocsPageParams> {
19
- params: Params;
20
- source: SourceBundle;
21
- }
22
- export type DocsPageAccessFilter<Params extends DocsPageParams = DocsPageParams> = (page: GeistdocsPage, context: DocsPageAccessContext<Params>) => boolean | Promise<boolean>;
23
- type DocsPageMdx = MDXComponents | ((context: {
24
- link: DocsPageLink;
25
- page: GeistdocsPage;
26
- source: SourceBundle;
27
- }) => MDXComponents);
28
- type OpenGraphImages = NonNullable<Metadata["openGraph"]>["images"];
29
- interface DocsPageOpenGraphOptions {
30
- images?: boolean | OpenGraphImages;
31
- }
32
- interface PageUrlContext<Params extends DocsPageParams = DocsPageParams> {
33
- page: GeistdocsPage;
34
- params: Params;
35
- }
36
- interface PublicPageUrlContext<Params extends DocsPageParams = DocsPageParams> extends PageUrlContext<Params> {
37
- pageUrl: string;
38
- }
39
- interface MarkdownUrlContext<Params extends DocsPageParams = DocsPageParams> extends PublicPageUrlContext<Params> {
40
- publicPageUrl: string;
41
- }
42
- export interface ResolvePageMarkdownUrlOptions {
43
- basePath?: string;
44
- isRootMountedPage?: boolean;
45
- pageUrl: string;
46
- publicPageUrl?: string;
47
- }
48
- export declare const resolvePageMarkdownUrl: (options: ResolvePageMarkdownUrlOptions) => string;
49
- interface DocsPageData extends GeistdocsPageVisibilityData {
50
- body: ComponentType<{
51
- components?: MDXComponents;
52
- }>;
53
- description?: string;
54
- full?: boolean;
55
- title: string;
56
- toc: ComponentProps<typeof FumadocsDocsPage>["toc"];
57
- }
58
- export interface CreateDocsPageOptions<Params extends DocsPageParams = DocsPageParams> {
59
- /** Return false to make a page unavailable for the current route params. */
60
- canViewPage?: DocsPageAccessFilter<Params>;
61
- config: Pick<GeistdocsConfig, "ai" | "basePath" | "defaultLanguage" | "feedback" | "github" | "pageActions" | "siteId" | "singleLanguage" | "siteUrl">;
62
- filterStaticParams?: (params: DocsPageParams) => boolean;
63
- getMarkdownUrl?: (context: MarkdownUrlContext<Params>) => string;
64
- getPageUrl?: (context: PageUrlContext<Params>) => string;
65
- getPublicPageUrl?: (context: PublicPageUrlContext<Params>) => string;
66
- mdx?: DocsPageMdx;
67
- metadata?: (context: {
68
- metadata: Metadata;
69
- page: GeistdocsPage;
70
- params: Params;
71
- }) => Metadata | Promise<Metadata>;
72
- openGraph?: DocsPageOpenGraphOptions;
73
- pageActions?: PageActionsBundle;
74
- /** Static content skips Markdown conversion; callbacks receive full context. */
75
- renderTop?: ReactNode | ((context: {
76
- data: DocsPageData;
77
- markdown: string;
78
- markdownUrl: string;
79
- page: GeistdocsPage;
80
- pageUrl: string;
81
- publicPageUrl: string;
82
- }) => ReactNode);
83
- resolveLink?: (context: {
84
- link: DocsPageLink;
85
- nativeLink: typeof NativeDocsLink;
86
- page: GeistdocsPage;
87
- source: SourceBundle;
88
- }) => DocsPageLink;
89
- source: SourceBundle;
90
- tableOfContent?: TableOfContentOptions;
91
- tableOfContentPopover?: ComponentProps<typeof FumadocsDocsPage>["tableOfContentPopover"];
92
- }
93
- /** A page factory with no implicit MDX registry; provide every named component. */
94
- export type CreateCustomDocsPageOptions<Params extends DocsPageParams = DocsPageParams> = Omit<CreateDocsPageOptions<Params>, "mdx"> & {
95
- mdx: DocsPageMdx;
96
- };
97
- export declare const createDocsPage: <Params extends DocsPageParams = DocsPageParams>({ canViewPage, config, source, mdx, pageActions, filterStaticParams, getMarkdownUrl, getPageUrl, getPublicPageUrl, metadata, openGraph, renderTop, resolveLink, tableOfContent, tableOfContentPopover, }: CreateCustomDocsPageOptions<Params>) => {
98
- Page: ({ params }: {
99
- params: Promise<Params>;
100
- }) => import("react/jsx-runtime").JSX.Element;
101
- getPageTree: (params: Params) => Promise<import("fumadocs-core/page-tree").Root>;
102
- generateStaticParams: () => (Omit<DocsPageParams, "lang"> & {
103
- lang?: string;
104
- })[];
105
- generateMetadata: ({ params, }: {
106
- params: Promise<Params>;
107
- }) => Promise<Metadata>;
108
- };
109
- export declare const createPageActions: ({ config, extraActions, getExtraActions, }: import("../internal/page-actions").CreatePageActionsOptions) => import("../internal/page-actions").CreatePageActionsOptions;
110
- export {};
111
- //# sourceMappingURL=docs-custom.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"docs-custom.d.ts","sourceRoot":"","sources":["../../src/pages/docs-custom.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,QAAQ,IAAI,gBAAgB,EAE7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAErC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAElB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,eAAe,EAA+B,MAAM,WAAW,CAAC;AAkB9E,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,KAAK,YAAY,GAAG,qBAAqB,CAAC;AAC1C,KAAK,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAChF,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,KAAK,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;AACvC,KAAK,qBAAqB,GAAG,WAAW,CACtC,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,CAC1D,CAAC;AACF,MAAM,WAAW,cACf,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC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@@ -1,250 +0,0 @@
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, resolveExtraPageActions, } 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
- import { getPageRobots, } from "../page-visibility";
24
- const renderPrefetchedDocsLink = (siteUrl, basePath, { children, className, href, rel, target, ...props }) => {
25
- const originalHref = String(href ?? "");
26
- const resolved = resolveLinkHref(originalHref, siteUrl);
27
- const linkHref = resolved.href === originalHref
28
- ? resolved.href
29
- : stripBasePathFromHref(resolved.href, basePath);
30
- return (_jsx(Link, { ...props, className: getDocsLinkClassName(className), href: linkHref, prefetch: !resolved.external, rel: resolved.external ? rel : undefined, target: resolved.external ? target : undefined, children: children }));
31
- };
32
- export const resolvePageMarkdownUrl = (options) => resolveInternalPageMarkdownUrl(options);
33
- /**
34
- * The page's visible article parts carry `data-geistdocs-article` (`title`,
35
- * `body`) so tools that read the rendered HTML (docs
36
- * crawlers, parity checks against the Markdown route) can select the
37
- * article without depending on Fumadocs' element ids or on class names.
38
- * The marked elements hold content only: page actions, breadcrumbs, the
39
- * table of contents, and the previous/next footer sit outside them.
40
- */
41
- const DocsTitle = ({ className, ...props }) => (_jsx(FumadocsDocsTitle, { className: cn("mb-4 text-balance", className), "data-geistdocs-article": "title", ...props }));
42
- const DocsBody = ({ className, ...props }) => (_jsx(FumadocsDocsBody, { className: cn("mx-auto w-full", className), "data-geistdocs-article": "body", ...props }));
43
- /** App-provided footer content below the table-of-contents actions. */
44
- const TocFooterSlot = ({ children }) => children ? _jsx("div", { className: "mt-4", children: children }) : null;
45
- const hasTableOfContentsActions = (config, extraActions) => config.pageActions?.scrollTop !== false ||
46
- config.feedback?.enabled !== false ||
47
- extraActions.length > 0;
48
- const serializeParams = (params) => JSON.stringify(Object.entries(params)
49
- .filter(([, value]) => value !== undefined)
50
- .sort(([left], [right]) => left.localeCompare(right)));
51
- export const createDocsPage = ({ canViewPage, config, source, mdx, pageActions = createInternalPageActions({ config }), filterStaticParams, getMarkdownUrl, getPageUrl, getPublicPageUrl, metadata, openGraph, renderTop, resolveLink, tableOfContent, tableOfContentPopover, }) => {
52
- const DocsLink = renderPrefetchedDocsLink.bind(null, config.siteUrl, config.basePath);
53
- const resolvePageUrls = (page, params) => {
54
- const pageUrl = getPageUrl?.({ page, params }) ?? page.url;
55
- const publicPageUrl = getPublicPageUrl?.({ page, params, pageUrl }) ??
56
- getPublicPath(pageUrl, config.basePath);
57
- const markdownUrl = getMarkdownUrl?.({ page, params, pageUrl, publicPageUrl }) ??
58
- resolveInternalPageMarkdownUrl({
59
- basePath: config.basePath,
60
- isRootMountedPage: source.baseUrl === "/" && page.slugs.length === 0,
61
- pageUrl,
62
- publicPageUrl,
63
- });
64
- return { markdownUrl, pageUrl, publicPageUrl };
65
- };
66
- const getAccessState = cache(async (paramsKey) => {
67
- const params = Object.fromEntries(JSON.parse(paramsKey));
68
- const tree = source.source.getPageTree(params.lang);
69
- if (!canViewPage) {
70
- return { tree, visibleUrls: undefined };
71
- }
72
- const access = await Promise.all(source.source.getPages(params.lang).map(async (page) => ({
73
- page,
74
- visible: await canViewPage(page, { params, source }),
75
- })));
76
- const visibleUrls = new Set(access.filter(({ visible }) => visible).map(({ page }) => page.url));
77
- const hiddenUrls = new Set(access.filter(({ visible }) => !visible).map(({ page }) => page.url));
78
- return { tree: filterPageTree(tree, hiddenUrls), visibleUrls };
79
- });
80
- // Single-language apps have no [lang] segment, so params arrive without it.
81
- const resolveParams = async (params) => {
82
- const resolved = await params;
83
- return {
84
- ...resolved,
85
- lang: resolveRouteLanguage(config, resolved.lang),
86
- };
87
- };
88
- const getPage = async (params) => {
89
- const page = source.source.getPage(params.slug, params.lang);
90
- if (!page) {
91
- notFound();
92
- }
93
- if (canViewPage) {
94
- const { visibleUrls } = await getAccessState(serializeParams(params));
95
- if (!visibleUrls?.has(page.url)) {
96
- notFound();
97
- }
98
- }
99
- return page;
100
- };
101
- const getPageTree = async (params) => (await getAccessState(serializeParams(params))).tree;
102
- const PageContent = async ({ params }) => {
103
- const resolvedParams = await resolveParams(params);
104
- const { lang } = resolvedParams;
105
- const page = await getPage(resolvedParams);
106
- const pageTree = await getPageTree(resolvedParams);
107
- const data = page.data;
108
- const MDX = data.body;
109
- const defaultLink = createRelativeDocsLink(source.source, page, DocsLink);
110
- const link = resolveLink
111
- ? resolveLink({
112
- link: defaultLink,
113
- nativeLink: NativeDocsLink,
114
- page,
115
- source,
116
- })
117
- : defaultLink;
118
- const resolvedMdx = typeof mdx === "function" ? mdx({ link, page, source }) : mdx;
119
- const { markdownUrl, pageUrl, publicPageUrl } = resolvePageUrls(page, resolvedParams);
120
- const footerItems = getPageFooterItems(pageTree, page.url);
121
- const pagesByUrl = getPageUrl
122
- ? new Map(source.source.getPages(lang).map((entry) => [entry.url, entry]))
123
- : undefined;
124
- const resolveFooterItem = (item) => {
125
- if (!(item && getPageUrl && pagesByUrl)) {
126
- return item;
127
- }
128
- const itemPage = pagesByUrl.get(item.url);
129
- if (!itemPage) {
130
- return item;
131
- }
132
- return {
133
- ...item,
134
- url: getPageUrl({
135
- page: itemPage,
136
- params: { ...resolvedParams, slug: itemPage.slugs },
137
- }),
138
- };
139
- };
140
- const resolvedFooterItems = {
141
- previous: resolveFooterItem(footerItems.previous),
142
- next: resolveFooterItem(footerItems.next),
143
- };
144
- const markdown = pageActions.getExtraActions || typeof renderTop === "function"
145
- ? await source.getPageMarkdown(page)
146
- : undefined;
147
- const footerActions = resolveExtraPageActions(pageActions, {
148
- markdown: markdown ?? "",
149
- page: {
150
- path: page.path,
151
- url: publicPageUrl,
152
- },
153
- });
154
- const hasTocActions = hasTableOfContentsActions(pageActions.config, footerActions);
155
- const hasTocLinks = Boolean(data.toc?.length);
156
- // Actions stay adjacent to the table of contents; the app-provided
157
- // footer (promos and other custom content) renders below them.
158
- 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 })] }));
159
- const tocComponent = tableOfContent?.component ?? (_jsx(GeistdocsTableOfContents, { footer: tocFooter, header: tableOfContent?.header, toc: data.toc ?? [] }));
160
- return (_jsxs(FumadocsDocsPage, { breadcrumb: {
161
- component: _jsx(PageBreadcrumb, { tree: pageTree, url: page.url }),
162
- }, footer: { component: _jsx(PageFooter, { ...resolvedFooterItems }) }, full: data.full, tableOfContent: {
163
- enabled: true,
164
- single: true,
165
- ...tableOfContent,
166
- component: tocComponent,
167
- }, tableOfContentPopover: {
168
- enabled: false,
169
- ...tableOfContentPopover,
170
- }, toc: data.toc, children: [typeof renderTop === "function"
171
- ? renderTop({
172
- data,
173
- markdown: markdown ?? "",
174
- markdownUrl,
175
- page,
176
- pageUrl,
177
- publicPageUrl,
178
- })
179
- : renderTop, _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: {
180
- markdownUrl,
181
- path: page.path,
182
- title: data.title,
183
- url: publicPageUrl,
184
- } })] }), _jsx("div", { className: "-mt-6 mb-4 @min-[961px]:hidden", children: _jsx(GeistdocsPageActions, { config: pageActions.config, only: "mobile", page: {
185
- markdownUrl,
186
- path: page.path,
187
- title: data.title,
188
- url: publicPageUrl,
189
- } }) }), _jsx(DocsBody, { children: _jsx(MDX, { components: {
190
- a: link,
191
- ...resolvedMdx,
192
- } }) })] }));
193
- };
194
- const Page = ({ params }) => (_jsx(DocsPageErrorBoundary, { children: _jsx(PageContent, { params: params }) }));
195
- const generateStaticParams = () => {
196
- const params = source.source.generateParams();
197
- const filtered = filterStaticParams
198
- ? params.filter(filterStaticParams)
199
- : params;
200
- return omitLanguageParam(config, filtered);
201
- };
202
- const generateMetadata = async ({ params, }) => {
203
- const resolvedParams = await resolveParams(params);
204
- const page = await getPage(resolvedParams);
205
- const pageTree = await getPageTree(resolvedParams);
206
- const data = page.data;
207
- const { markdownUrl, publicPageUrl } = resolvePageUrls(page, resolvedParams);
208
- const openGraphImages = openGraph?.images === true
209
- ? source.getPageImage(page).url
210
- : openGraph?.images;
211
- let canonicalUrl;
212
- if (data.canonical) {
213
- canonicalUrl = withBasePath(data.canonical, config.basePath);
214
- }
215
- else if (config.siteUrl) {
216
- canonicalUrl = new URL(publicPageUrl, config.siteUrl).toString();
217
- }
218
- const defaultMetadata = {
219
- title: resolveDocumentTitle({
220
- pageTitle: data.title,
221
- pageUrl: page.url,
222
- tree: pageTree,
223
- }),
224
- description: data.description,
225
- keywords: data.keywords,
226
- robots: getPageRobots(page),
227
- ...(openGraphImages ? { openGraph: { images: openGraphImages } } : {}),
228
- alternates: {
229
- canonical: canonicalUrl,
230
- types: {
231
- "text/markdown": markdownUrl,
232
- },
233
- },
234
- };
235
- return metadata
236
- ? await metadata({
237
- metadata: defaultMetadata,
238
- page,
239
- params: resolvedParams,
240
- })
241
- : defaultMetadata;
242
- };
243
- return {
244
- Page,
245
- getPageTree,
246
- generateStaticParams,
247
- generateMetadata,
248
- };
249
- };
250
- export const createPageActions = createInternalPageActions;
@@ -1,22 +0,0 @@
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.
@@ -1,15 +0,0 @@
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 };
@@ -1,116 +0,0 @@
1
- import { DATA_QUERY, withoutDataQuery } from "./data-projection.mjs";
2
-
3
- const MDX_EXTENSION = /\.mdx?$/;
4
- const ORIGINAL_EMIT = Symbol.for("geistdocs.data-entry.original-emit");
5
-
6
- /**
7
- * Opt-in Fumadocs 14 plugin. Extend the existing index-file emitter in place:
8
- * its own watcher calls core.emitAndWrite filtered to name === "index-file".
9
- * Registering an independent emitter would miss those development updates.
10
- */
11
- export function dataEntryPlugin(typeScriptOrLoader) {
12
- let parserPromise;
13
- const getParser = () =>
14
- (parserPromise ??= Promise.resolve()
15
- .then(() =>
16
- typeof typeScriptOrLoader === "function"
17
- ? typeScriptOrLoader()
18
- : typeScriptOrLoader
19
- )
20
- .then((module) => module.default ?? module));
21
- return {
22
- name: "geistdocs-data-entry",
23
- config() {
24
- const indexes = this.core
25
- .getPlugins()
26
- .filter((plugin) => plugin.name === "index-file");
27
- // The webpack/Turbopack compiler core has no discovery/index emitter.
28
- // It still loads the same site config to run frontmatter and doc hooks.
29
- if (indexes.length === 0 && this.environment === "webpack") {
30
- return;
31
- }
32
- if (indexes.length !== 1 || typeof indexes[0].emit !== "function") {
33
- throw new Error("Data entries require one Fumadocs index-file emitter");
34
- }
35
- const index = indexes[0];
36
- const original = index.emit[ORIGINAL_EMIT] ?? index.emit;
37
- const emit = async function () {
38
- const entries = await original.call(this);
39
- const server = entries.find((entry) => entry.path === "server.ts");
40
- if (!server || entries.some((entry) => entry.path === "data.ts")) {
41
- throw new Error(
42
- "Data entries require server.ts and an unused data.ts output"
43
- );
44
- }
45
- // Compiler workers load config but never emit indexes. Keep TypeScript
46
- // out of their initialization path; the host supplies a lazy import.
47
- const ts = await getParser();
48
- return [
49
- ...entries,
50
- {
51
- path: "data.ts",
52
- content: createDataEntry(server.content, ts).code,
53
- },
54
- ];
55
- };
56
- emit[ORIGINAL_EMIT] = original;
57
- index.emit = emit;
58
- },
59
- };
60
- }
61
-
62
- /**
63
- * Derive data.ts from Fumadocs' authoritative generated server.ts in the SAME
64
- * directory. Call from the existing generation lifecycle after each emission.
65
- * No globbing, watcher, filesystem writes or extra content registry is created.
66
- * TypeScript is supplied by the build-time host, not a runtime dependency.
67
- */
68
- export function createDataEntry(serverCode, ts) {
69
- const file = ts.createSourceFile(
70
- "server.ts",
71
- serverCode,
72
- ts.ScriptTarget.Latest,
73
- true,
74
- ts.ScriptKind.TS
75
- );
76
- if (file.parseDiagnostics.length) {
77
- throw new Error("Cannot parse generated server entry");
78
- }
79
- const edits = [];
80
- for (const statement of file.statements) {
81
- if (
82
- !(
83
- ts.isImportDeclaration(statement) &&
84
- ts.isStringLiteral(statement.moduleSpecifier)
85
- )
86
- ) {
87
- continue;
88
- }
89
- const specifier = statement.moduleSpecifier;
90
- const separator = specifier.text.indexOf("?");
91
- const pathname =
92
- separator < 0 ? specifier.text : specifier.text.slice(0, separator);
93
- if (!MDX_EXTENSION.test(pathname)) {
94
- continue;
95
- }
96
- const query = new URLSearchParams(
97
- separator < 0 ? "" : specifier.text.slice(separator + 1)
98
- );
99
- // Only collection imports emitted by Fumadocs; preserve metadata JSON and
100
- // unrelated modules, runtime options, passthroughs and collection order.
101
- if (!query.has("collection") || query.has("only")) {
102
- continue;
103
- }
104
- const canonicalQuery = withoutDataQuery(specifier.text.slice(separator));
105
- edits.push({
106
- start: specifier.getStart(file),
107
- end: specifier.end,
108
- value: JSON.stringify(`${pathname}${canonicalQuery}&${DATA_QUERY}=1`),
109
- });
110
- }
111
- let code = serverCode;
112
- for (const edit of edits.reverse()) {
113
- code = code.slice(0, edit.start) + edit.value + code.slice(edit.end);
114
- }
115
- return { code, imports: edits.length };
116
- }