@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
package/dist/next.js CHANGED
@@ -1,76 +1,8 @@
1
- import { fileURLToPath } from "node:url";
2
1
  import { createMDX } from "fumadocs-mdx/next";
2
+ import { PHASE_PRODUCTION_SERVER } from "next/constants.js";
3
+ import { prepareSearchIndex, skipSearchIndexGeneration, } from "../search-index.js";
3
4
  import { APP_ROUTE_MANIFEST_DEFINE, APP_ROUTE_MANIFEST_ENV, } from "./internal/app-route-manifest.js";
4
5
  import { mergeRewriteRoutes, scanAppRouteManifest, } from "./internal/app-route-scanner.js";
5
- const FUMADOCS_MDX_LOADER = "fumadocs-mdx/loader-mdx";
6
- /** Replace only Fumadocs' MDX loader, preserving config and user rules. */
7
- const replaceMdxLoader = (config, loader, mode) => {
8
- const replace = (entry) => {
9
- if (entry === FUMADOCS_MDX_LOADER) {
10
- return { loader, options: { geistdocsMdxCompiler: mode } };
11
- }
12
- if (entry &&
13
- typeof entry === "object" &&
14
- "loader" in entry &&
15
- entry.loader === FUMADOCS_MDX_LOADER) {
16
- const options = "options" in entry && entry.options && typeof entry.options === "object"
17
- ? entry.options
18
- : {};
19
- return {
20
- ...entry,
21
- loader,
22
- options: { ...options, geistdocsMdxCompiler: mode },
23
- };
24
- }
25
- return entry;
26
- };
27
- const rules = config.turbopack?.rules;
28
- const turbopack = rules
29
- ? {
30
- ...config.turbopack,
31
- rules: Object.fromEntries(Object.entries(rules).map(([pattern, rule]) => {
32
- if (!(rule &&
33
- typeof rule === "object" &&
34
- "loaders" in rule &&
35
- rule.loaders)) {
36
- return [pattern, rule];
37
- }
38
- return [pattern, { ...rule, loaders: rule.loaders.map(replace) }];
39
- })),
40
- }
41
- : config.turbopack;
42
- function rewriteRule(entry) {
43
- if (!entry || typeof entry !== "object") {
44
- return;
45
- }
46
- const rule = entry;
47
- for (const key of ["oneOf", "rules"]) {
48
- if (Array.isArray(rule[key])) {
49
- rewriteRules(rule[key]);
50
- }
51
- }
52
- if (rule.loader === FUMADOCS_MDX_LOADER) {
53
- Object.assign(rule, replace(rule));
54
- }
55
- if (Array.isArray(rule.use)) {
56
- rule.use = rule.use.map(replace);
57
- }
58
- else if (rule.use) {
59
- rule.use = replace(rule.use);
60
- }
61
- }
62
- function rewriteRules(entries) {
63
- for (const entry of entries) {
64
- rewriteRule(entry);
65
- }
66
- }
67
- const webpack = (input, context) => {
68
- const output = config.webpack?.(input, context) ?? input;
69
- rewriteRules(output.module?.rules ?? []);
70
- return output;
71
- };
72
- return { ...config, turbopack, webpack };
73
- };
74
6
  const hasOwn = (value, key) => value ? Object.hasOwn(value, key) : false;
75
7
  const assertManifestKeyIsAvailable = (config) => {
76
8
  if (hasOwn(config.env, APP_ROUTE_MANIFEST_ENV) ||
@@ -86,21 +18,12 @@ const flattenRewrites = (rewrites) => Array.isArray(rewrites)
86
18
  ...(rewrites.afterFiles ?? []),
87
19
  ...(rewrites.fallback ?? []),
88
20
  ];
89
- /** Compose Fumadocs MDX with Geistdocs App Router discovery. */
90
- export const createGeistdocs = (options = {}) => {
91
- const { experimentalMdxLoader, mdxCompiler = "auto", ...mdxOptions } = options;
92
- if (!["auto", "native", "js"].includes(mdxCompiler)) {
93
- throw new Error(`Invalid mdxCompiler: ${mdxCompiler}`);
94
- }
95
- const withMDX = createMDX(mdxOptions);
96
- const mdxLoader = experimentalMdxLoader ??
97
- process.env.GEISTDOCS_MDX_LOADER ??
98
- fileURLToPath(new URL("../native-mdx/loader-mdx.cjs", import.meta.url));
99
- return async (nextConfig = {}) => {
100
- const withFumadocs = withMDX(await nextConfig);
101
- const config = mdxCompiler === "js"
102
- ? withFumadocs
103
- : replaceMdxLoader(withFumadocs, mdxLoader, mdxCompiler);
21
+ export function createGeistdocs(options = {}) {
22
+ const { searchIndex, ...mdxOptions } = options;
23
+ let withMDX;
24
+ const resolveConfig = async (nextConfig = {}) => {
25
+ withMDX ??= createMDX(mdxOptions);
26
+ const config = withMDX(await nextConfig);
104
27
  const resolvedRewrites = config.rewrites
105
28
  ? await config.rewrites()
106
29
  : undefined;
@@ -129,4 +52,23 @@ export const createGeistdocs = (options = {}) => {
129
52
  },
130
53
  };
131
54
  };
132
- };
55
+ if (!searchIndex) {
56
+ return resolveConfig;
57
+ }
58
+ let prepared;
59
+ return (nextConfig = {}) => async (phase) => {
60
+ if (phase === PHASE_PRODUCTION_SERVER) {
61
+ skipSearchIndexGeneration(mdxOptions);
62
+ }
63
+ else {
64
+ // Fumadocs does not await its own codegen. Prepare search modules before
65
+ // bundling, but never read/parse source content in a production server.
66
+ prepared ??= prepareSearchIndex(mdxOptions).catch((error) => {
67
+ prepared = undefined;
68
+ throw error;
69
+ });
70
+ await prepared;
71
+ }
72
+ return resolveConfig(nextConfig);
73
+ };
74
+ }
@@ -1,7 +1,95 @@
1
- import { type CreateDocsPageOptions, type DocsPageParams } from "./docs-custom";
2
- export { type CreateDocsPageOptions, createPageActions, type DocsPageAccessContext, type DocsPageAccessFilter, type DocsPageParams, type ResolvePageMarkdownUrlOptions, resolvePageMarkdownUrl, } from "./docs-custom";
3
- /** The default factory keeps the complete Geistdocs MDX component registry. */
4
- export declare const createDocsPage: <Params extends DocsPageParams = DocsPageParams>(options: CreateDocsPageOptions<Params>) => {
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
+ renderTop?: (context: {
75
+ data: DocsPageData;
76
+ markdown: string;
77
+ markdownUrl: string;
78
+ page: GeistdocsPage;
79
+ pageUrl: string;
80
+ publicPageUrl: string;
81
+ }) => ReactNode;
82
+ resolveLink?: (context: {
83
+ link: DocsPageLink;
84
+ nativeLink: typeof NativeDocsLink;
85
+ page: GeistdocsPage;
86
+ source: SourceBundle;
87
+ }) => DocsPageLink;
88
+ source: SourceBundle;
89
+ tableOfContent?: TableOfContentOptions;
90
+ tableOfContentPopover?: ComponentProps<typeof FumadocsDocsPage>["tableOfContentPopover"];
91
+ }
92
+ export declare const createDocsPage: <Params extends DocsPageParams = DocsPageParams>({ canViewPage, config, source, mdx, pageActions, filterStaticParams, getMarkdownUrl, getPageUrl, getPublicPageUrl, metadata, openGraph, renderTop, resolveLink, tableOfContent, tableOfContentPopover, }: CreateDocsPageOptions<Params>) => {
5
93
  Page: ({ params }: {
6
94
  params: Promise<Params>;
7
95
  }) => import("react/jsx-runtime").JSX.Element;
@@ -11,6 +99,11 @@ export declare const createDocsPage: <Params extends DocsPageParams = DocsPagePa
11
99
  })[];
12
100
  generateMetadata: ({ params, }: {
13
101
  params: Promise<Params>;
14
- }) => Promise<import("next").Metadata>;
102
+ }) => Promise<Metadata>;
15
103
  };
104
+ export declare const createPageActions: ({ config, getExtraActions, }: import("../internal/page-actions").CreatePageActionsOptions) => {
105
+ config: Pick<GeistdocsConfig, "ai" | "feedback" | "github" | "pageActions" | "siteId">;
106
+ getExtraActions: ((context: import("../internal/page-actions").PageActionRenderContext) => ReactNode[]) | undefined;
107
+ };
108
+ export {};
16
109
  //# sourceMappingURL=docs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/pages/docs.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB,+EAA+E;AAC/E,eAAO,MAAM,cAAc,GAAI,MAAM,SAAS,cAAc,GAAG,cAAc,EAC3E,SAAS,qBAAqB,CAAC,MAAM,CAAC;;;;;;;;;;;CAUpC,CAAC"}
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/pages/docs.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;AAgB9E,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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AM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE;0BAvKlB,MAAM;;;;oCAwLtC;QACD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;KACzB,KAAG,OAAO,CAAC,QAAQ,CAAC;CAqDtB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;CAA4B,CAAC"}
@@ -1,14 +1,251 @@
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";
1
23
  import { createMdxComponents } from "../mdx";
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
- });
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;
@@ -7,9 +7,16 @@ type SearchSourceInput = SearchSource | SourceBundle;
7
7
  interface CreateSearchRouteOptions {
8
8
  config: Pick<GeistdocsConfig, "defaultLanguage" | "translations">;
9
9
  filterPage?: GeistdocsPageFilter<ReturnType<SearchSource["getPages"]>[number], SearchSourceInput>;
10
+ /**
11
+ * Load sources on the first nonempty query for a configured locale.
12
+ * Mutually exclusive with source/sources; successful loads are cached.
13
+ * Use a dynamic import of a separate search-only source module: sources
14
+ * imported by the caller still evaluate eagerly.
15
+ */
16
+ loadSources?: () => Promise<SearchSourceInput[]>;
10
17
  source?: SearchSourceInput;
11
18
  sources?: SearchSourceInput[];
12
19
  }
13
- export declare const createSearchRoute: ({ config, filterPage, source, sources, }: CreateSearchRouteOptions) => (request: Request) => Promise<Response>;
20
+ export declare const createSearchRoute: ({ config, filterPage, loadSources, source, sources, }: CreateSearchRouteOptions) => (request: Request) => Promise<Response>;
14
21
  export {};
15
22
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/routes/search.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAOjD,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,qBAAqB,EAA2B,MAAM,WAAW,CAAC;AAEhF,KAAK,YAAY,GAAG,qBAAqB,CAAC;AAC1C,KAAK,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC3C,KAAK,iBAAiB,GAAG,YAAY,GAAG,YAAY,CAAC;AAIrD,UAAU,wBAAwB;IAChC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,UAAU,CAAC,EAAE,mBAAmB,CAC9B,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,EAC5C,iBAAiB,CAClB,CAAC;IACF,MAAM,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