@vercel/geistdocs 1.25.1-canary.5684bb5 → 1.25.1-canary.93b1a3a

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 (90) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/components/callout.d.ts.map +1 -1
  3. package/dist/components/callout.js +3 -3
  4. package/dist/components/code-block-tabs.d.ts.map +1 -1
  5. package/dist/components/code-block-tabs.js +3 -1
  6. package/dist/components/code-block.d.ts.map +1 -1
  7. package/dist/components/code-block.js +1 -1
  8. package/dist/components/command-prompt.d.ts.map +1 -1
  9. package/dist/components/command-prompt.js +15 -22
  10. package/dist/components/copy-prompt.d.ts +2 -1
  11. package/dist/components/copy-prompt.d.ts.map +1 -1
  12. package/dist/components/copy-prompt.js +2 -2
  13. package/dist/components/heading.d.ts +7 -0
  14. package/dist/components/heading.d.ts.map +1 -0
  15. package/dist/components/heading.js +14 -0
  16. package/dist/components/table.d.ts +3 -0
  17. package/dist/components/table.d.ts.map +1 -0
  18. package/dist/components/table.js +3 -0
  19. package/dist/controls.d.ts.map +1 -1
  20. package/dist/controls.js +4 -3
  21. package/dist/internal/chat/context.d.ts +2 -0
  22. package/dist/internal/chat/context.d.ts.map +1 -1
  23. package/dist/internal/chat/context.js +24 -3
  24. package/dist/internal/chat/dots-spinner.d.ts.map +1 -1
  25. package/dist/internal/chat/dots-spinner.js +15 -9
  26. package/dist/internal/chat/loading-skeleton.d.ts +7 -0
  27. package/dist/internal/chat/loading-skeleton.d.ts.map +1 -0
  28. package/dist/internal/chat/loading-skeleton.js +46 -0
  29. package/dist/internal/chat/message.d.ts.map +1 -1
  30. package/dist/internal/chat/message.js +23 -3
  31. package/dist/internal/chat/shell.d.ts.map +1 -1
  32. package/dist/internal/chat/shell.js +10 -15
  33. package/dist/internal/chat/sources.d.ts.map +1 -1
  34. package/dist/internal/chat/sources.js +4 -1
  35. package/dist/internal/mousedown-navigation-utils.d.ts +5 -0
  36. package/dist/internal/mousedown-navigation-utils.d.ts.map +1 -0
  37. package/dist/internal/mousedown-navigation-utils.js +95 -0
  38. package/dist/internal/mousedown-navigation.d.ts +10 -0
  39. package/dist/internal/mousedown-navigation.d.ts.map +1 -0
  40. package/dist/internal/mousedown-navigation.js +42 -0
  41. package/dist/internal/navbar/desktop-menu.js +1 -1
  42. package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
  43. package/dist/internal/navbar/mobile-menu.js +8 -13
  44. package/dist/internal/navbar/navbar-shell.d.ts.map +1 -1
  45. package/dist/internal/navbar/navbar-shell.js +2 -1
  46. package/dist/internal/page-actions-client.d.ts.map +1 -1
  47. package/dist/internal/page-actions-client.js +36 -32
  48. package/dist/internal/provider-client.d.ts.map +1 -1
  49. package/dist/internal/provider-client.js +29 -5
  50. package/dist/internal/search.d.ts.map +1 -1
  51. package/dist/internal/search.js +1 -1
  52. package/dist/internal/sidebar-responsive.d.ts +0 -1
  53. package/dist/internal/sidebar-responsive.d.ts.map +1 -1
  54. package/dist/internal/sidebar-responsive.js +0 -9
  55. package/dist/internal/sidebar.d.ts.map +1 -1
  56. package/dist/internal/sidebar.js +78 -49
  57. package/dist/internal/table-of-contents.d.ts.map +1 -1
  58. package/dist/internal/table-of-contents.js +1 -1
  59. package/dist/internal/toc-items.d.ts.map +1 -1
  60. package/dist/internal/toc-items.js +16 -6
  61. package/dist/internal/ui/dropdown-menu.js +6 -6
  62. package/dist/internal/ui/navigation-menu.js +2 -2
  63. package/dist/internal/use-mobile.d.ts.map +1 -1
  64. package/dist/internal/use-mobile.js +2 -12
  65. package/dist/layout.d.ts +1 -0
  66. package/dist/layout.d.ts.map +1 -1
  67. package/dist/layout.js +2 -0
  68. package/dist/mdx.d.ts.map +1 -1
  69. package/dist/mdx.js +11 -4
  70. package/dist/pages/docs.d.ts.map +1 -1
  71. package/dist/pages/docs.js +8 -5
  72. package/dist/routes/chat.d.ts +1 -1
  73. package/dist/routes/chat.js +1 -1
  74. package/dist/versions.js +2 -2
  75. package/docs/agents.md +1 -1
  76. package/docs/llms.txt +99 -7
  77. package/docs/manifest.json +1 -1
  78. package/docs/pages/ask-ai.md +2 -2
  79. package/docs/pages/md.md +1 -1
  80. package/docs/pages/syntax.md +95 -3
  81. package/package.json +3 -2
  82. package/template/app/[lang]/layout.tsx +4 -0
  83. package/template/app/styles/geistdocs.css +1 -1
  84. package/template/components/ui/button.tsx +1 -1
  85. package/template/content/docs/ask-ai.cn.mdx +2 -2
  86. package/template/content/docs/ask-ai.mdx +2 -2
  87. package/template/content/docs/md.mdx +1 -1
  88. package/template/content/docs/syntax.mdx +101 -3
  89. package/template/package.json +2 -2
  90. package/theme.css +33 -60
@@ -189,26 +189,21 @@ const GeistdocsChatErrorBoundary = catchError(GeistdocsChatErrorFallback);
189
189
  export const GeistdocsChatShell = () => {
190
190
  const { enabled, isOpen, setIsOpen } = useGeistdocsChat();
191
191
  const isMobile = useIsMobile();
192
- useEffect(() => {
193
- const handleKeyDown = (event) => {
194
- if ((event.metaKey || event.ctrlKey) &&
195
- !event.altKey &&
196
- !event.shiftKey &&
197
- event.key.toLowerCase() === "i") {
198
- event.preventDefault();
199
- setIsOpen((prev) => !prev);
200
- }
201
- };
202
- window.addEventListener("keydown", handleKeyDown);
203
- return () => window.removeEventListener("keydown", handleKeyDown);
204
- }, [setIsOpen]);
205
192
  if (!enabled) {
206
193
  return null;
207
194
  }
208
- return (_jsxs(_Fragment, { children: [_jsx(Portal.Root, { className: "hidden md:block", children: _jsx("div", { className: cn(
195
+ return (_jsxs(_Fragment, { children: [isOpen ? (_jsx("style", { children: `
196
+ html {
197
+ scrollbar-width: none !important;
198
+ -ms-overflow-style: none !important;
199
+ }
200
+ html::-webkit-scrollbar {
201
+ display: none !important;
202
+ }
203
+ ` })) : null, _jsx(Portal.Root, { children: _jsx("div", { className: cn(
209
204
  // z-45 keeps the panel above the sticky navbar (z-40) but below
210
205
  // modal surfaces like the search command menu, dialogs, and
211
206
  // dropdowns (z-50), so opening the command menu paints over an
212
207
  // open chat panel.
213
- "fixed inset-y-0 right-0 z-45 flex h-full w-[400px] max-w-[75vw] flex-col gap-4 border-l bg-background-100 transition-all", "translate-x-full data-[state=open]:translate-x-0"), "data-state": isOpen ? "open" : "closed", children: _jsx(GeistdocsChatErrorBoundary, { onClose: () => setIsOpen(false), children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) }) }) }), _jsx("div", { className: "md:hidden", children: _jsxs(Drawer, { className: "flex flex-col bg-background-100", height: "80dvh", onDismiss: () => setIsOpen(false), show: isMobile && isOpen, children: [_jsx(DrawerTitle, { className: "sr-only", children: "Ask AI" }), _jsx(GeistdocsChatErrorBoundary, { onClose: () => setIsOpen(false), children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) })] }) })] }));
208
+ "fixed inset-y-0 right-0 z-45 hidden h-full w-[400px] max-w-[75vw] flex-col gap-4 border-l bg-background-100 transition-transform min-[768px]:flex", "translate-x-full data-[state=open]:translate-x-0"), "data-state": isOpen ? "open" : "closed", children: _jsx(GeistdocsChatErrorBoundary, { onClose: () => setIsOpen(false), children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) }) }) }), _jsx("div", { className: "min-[768px]:hidden", children: _jsxs(Drawer, { className: "flex flex-col bg-background-100", height: "80dvh", onDismiss: () => setIsOpen(false), show: isMobile && isOpen, children: [_jsx(DrawerTitle, { className: "sr-only", children: "Ask AI" }), _jsx(GeistdocsChatErrorBoundary, { onClose: () => setIsOpen(false), children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) })] }) })] }));
214
209
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/sources.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAEL,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AAEjD,eAAO,MAAM,OAAO,GAAI,yBAAyB,YAAY,4CAK5D,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,kBAAkB,CAAC,GAAG;IAC5E,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,0CAK5B,mBAAmB,4CAerB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE5E,eAAO,MAAM,cAAc,GAAI,yBAG5B,mBAAmB,4CAErB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjE,eAAO,MAAM,MAAM,GAAI,qCAAqC,WAAW,4CAYtE,CAAC"}
1
+ {"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/sources.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAEL,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AAEjD,eAAO,MAAM,OAAO,GAAI,yBAAyB,YAAY,4CAK5D,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,kBAAkB,CAAC,GAAG;IAC5E,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,0CAK5B,mBAAmB,4CAerB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE5E,eAAO,MAAM,cAAc,GAAI,yBAG5B,mBAAmB,4CAErB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjE,eAAO,MAAM,MAAM,GAAI,qCAAqC,WAAW,4CAgBtE,CAAC"}
@@ -6,4 +6,7 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "../ui/coll
6
6
  export const Sources = ({ className, ...props }) => (_jsx(Collapsible, { className: cn("not-prose text-gray-600 text-xs", className), ...props }));
7
7
  export const SourcesTrigger = ({ className, count, children, ...props }) => (_jsx(CollapsibleTrigger, { className: cn("group flex items-center rounded-md border-none bg-transparent", className), ...props, children: children ?? (_jsxs(_Fragment, { children: [_jsxs("p", { className: "font-medium", children: ["Used ", count, " sources"] }), _jsx(IconChevronDown, { className: "h-4 w-4 transition-transform duration-200 group-data-[state=open]:rotate-180" })] })) }));
8
8
  export const SourcesContent = ({ className, ...props }) => (_jsx(CollapsibleContent, { className: cn("flex flex-col", className), ...props }));
9
- export const Source = ({ href, title, children, ...props }) => (_jsx("a", { className: "inline-flex min-w-0 max-w-full items-center underline underline-offset-1", href: href, rel: "noreferrer", target: "_blank", ...props, children: children ?? (_jsx("span", { className: "truncate font-medium text-gray-1000", children: title })) }));
9
+ export const Source = ({ href, title, children, ...props }) => {
10
+ const external = href.startsWith("http://") || href.startsWith("https://");
11
+ return (_jsx("a", { className: "inline-flex min-w-0 max-w-full items-center underline underline-offset-1", href: href, rel: external ? "noreferrer" : undefined, target: external ? "_blank" : undefined, ...props, children: children ?? (_jsx("span", { className: "truncate font-medium text-gray-1000", children: title })) }));
12
+ };
@@ -0,0 +1,5 @@
1
+ import type { PointerEvent as ReactPointerEvent } from "react";
2
+ export declare const getMouseDownRouterHref: (href: string, basePath: string | undefined) => string;
3
+ export declare const findMouseDownNavigationAnchor: (target: EventTarget | null, boundary: EventTarget | null) => HTMLAnchorElement | null;
4
+ export declare const shouldNavigateOnPointerDown: (event: ReactPointerEvent, anchor: HTMLAnchorElement) => boolean;
5
+ //# sourceMappingURL=mousedown-navigation-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mousedown-navigation-utils.d.ts","sourceRoot":"","sources":["../../src/internal/mousedown-navigation-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAwB/D,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,EACZ,UAAU,MAAM,GAAG,SAAS,WAoB7B,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,WAAW,GAAG,IAAI,EAC1B,UAAU,WAAW,GAAG,IAAI,KAC3B,iBAAiB,GAAG,IAWtB,CAAC;AAyBF,eAAO,MAAM,2BAA2B,GACtC,OAAO,iBAAiB,EACxB,QAAQ,iBAAiB,YA0C1B,CAAC"}
@@ -0,0 +1,95 @@
1
+ const TRAILING_SLASH_PATTERN = /\/$/;
2
+ const normalizeRouterBasePath = (basePath) => {
3
+ if (!basePath || basePath === "/") {
4
+ return "";
5
+ }
6
+ const normalized = basePath.startsWith("/") ? basePath : `/${basePath}`;
7
+ return normalized.replace(TRAILING_SLASH_PATTERN, "");
8
+ };
9
+ const NESTED_CONTROL_TAGS = new Set([
10
+ "BUTTON",
11
+ "INPUT",
12
+ "LABEL",
13
+ "SELECT",
14
+ "SUMMARY",
15
+ "TEXTAREA",
16
+ ]);
17
+ const HANDLED_KEY = "__geistdocsMouseDownNavigationHandled";
18
+ export const getMouseDownRouterHref = (href, basePath) => {
19
+ const normalizedBasePath = normalizeRouterBasePath(basePath);
20
+ if (!normalizedBasePath) {
21
+ return href;
22
+ }
23
+ try {
24
+ const url = new URL(href, window.location.origin);
25
+ if (url.pathname === normalizedBasePath) {
26
+ return `/${url.search}${url.hash}`;
27
+ }
28
+ if (url.pathname.startsWith(`${normalizedBasePath}/`)) {
29
+ return `${url.pathname.slice(normalizedBasePath.length)}${url.search}${url.hash}`;
30
+ }
31
+ }
32
+ catch {
33
+ return href;
34
+ }
35
+ return href;
36
+ };
37
+ export const findMouseDownNavigationAnchor = (target, boundary) => {
38
+ let element = target;
39
+ while (element && element !== boundary) {
40
+ if (element.tagName === "A") {
41
+ return element;
42
+ }
43
+ element = element.parentElement;
44
+ }
45
+ return null;
46
+ };
47
+ const startsOnNestedControl = (target, anchor) => {
48
+ if (anchor.hasAttribute("data-no-mousedown-nav")) {
49
+ return true;
50
+ }
51
+ let element = target;
52
+ while (element && element !== anchor) {
53
+ if (element.hasAttribute("data-no-mousedown-nav") ||
54
+ NESTED_CONTROL_TAGS.has(element.tagName) ||
55
+ element.getAttribute("role") === "button") {
56
+ return true;
57
+ }
58
+ element = element.parentElement;
59
+ }
60
+ return false;
61
+ };
62
+ export const shouldNavigateOnPointerDown = (event, anchor) => {
63
+ if (event.defaultPrevented ||
64
+ event.button !== 0 ||
65
+ event.pointerType !== "mouse" ||
66
+ event.altKey ||
67
+ event.ctrlKey ||
68
+ event.metaKey ||
69
+ event.shiftKey ||
70
+ startsOnNestedControl(event.target, anchor)) {
71
+ return false;
72
+ }
73
+ const nativeEvent = event.nativeEvent;
74
+ if (nativeEvent[HANDLED_KEY] === true) {
75
+ return false;
76
+ }
77
+ const target = anchor.getAttribute("target");
78
+ if ((target && target !== "_self") || anchor.hasAttribute("download")) {
79
+ return false;
80
+ }
81
+ const href = anchor.getAttribute("href");
82
+ if (!href || href.startsWith("#")) {
83
+ return false;
84
+ }
85
+ try {
86
+ if (new URL(href, window.location.origin).origin !== window.location.origin) {
87
+ return false;
88
+ }
89
+ }
90
+ catch {
91
+ return false;
92
+ }
93
+ nativeEvent[HANDLED_KEY] = true;
94
+ return true;
95
+ };
@@ -0,0 +1,10 @@
1
+ import { type ReactNode } from "react";
2
+ /**
3
+ * Starts same-origin mouse navigation on pointer down, matching Vercel's
4
+ * marketing navbar behavior. Browser click behavior remains the fallback for
5
+ * keyboard activation, touch, modified clicks, downloads, and external links.
6
+ */
7
+ export declare const MouseDownNavigation: ({ children }: {
8
+ children: ReactNode;
9
+ }) => import("react/jsx-runtime").JSX.Element;
10
+ //# sourceMappingURL=mousedown-navigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mousedown-navigation.d.ts","sourceRoot":"","sources":["../../src/internal/mousedown-navigation.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAQf;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,cAAc;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,4CAkDxE,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useRouter } from "next/navigation";
4
+ import { useCallback, useRef, } from "react";
5
+ import { useGeistdocsConfig } from "./config-context";
6
+ import { findMouseDownNavigationAnchor, getMouseDownRouterHref, shouldNavigateOnPointerDown, } from "./mousedown-navigation-utils";
7
+ /**
8
+ * Starts same-origin mouse navigation on pointer down, matching Vercel's
9
+ * marketing navbar behavior. Browser click behavior remains the fallback for
10
+ * keyboard activation, touch, modified clicks, downloads, and external links.
11
+ */
12
+ export const MouseDownNavigation = ({ children }) => {
13
+ const router = useRouter();
14
+ const { basePath } = useGeistdocsConfig();
15
+ const navigated = useRef(false);
16
+ const onPointerDownCapture = useCallback((event) => {
17
+ // A drag-off has no follow-up click inside this wrapper. Clear stale
18
+ // state at the beginning of every pointer interaction.
19
+ navigated.current = false;
20
+ const anchor = findMouseDownNavigationAnchor(event.target, event.currentTarget);
21
+ if (!(anchor && shouldNavigateOnPointerDown(event, anchor))) {
22
+ return;
23
+ }
24
+ const href = anchor.getAttribute("href");
25
+ if (!href) {
26
+ return;
27
+ }
28
+ navigated.current = true;
29
+ router.push(getMouseDownRouterHref(href, basePath), {
30
+ scroll: anchor.getAttribute("data-scroll") !== "false",
31
+ });
32
+ }, [basePath, router]);
33
+ const onClickCapture = useCallback((event) => {
34
+ if (navigated.current) {
35
+ // Prevent Next.js/the browser from navigating a second time without
36
+ // stopping propagation, so click handlers and analytics still run.
37
+ event.preventDefault();
38
+ navigated.current = false;
39
+ }
40
+ }, []);
41
+ return (_jsx("div", { onClickCapture: onClickCapture, onPointerDownCapture: onPointerDownCapture, style: { display: "contents" }, children: children }));
42
+ };
@@ -49,5 +49,5 @@ const DropdownNavItem = ({ first, item, }) => {
49
49
  export const DesktopMenu = ({ items, className }) => {
50
50
  const isActive = useNavActive();
51
51
  const [navOpen, setNavOpen] = useState(false);
52
- return (_jsxs(_Fragment, { children: [_jsx(NavigationMenu, { "aria-label": "Primary navigation", delayDuration: 0, onValueChange: (value) => setNavOpen(Boolean(value)), skipDelayDuration: 0, viewport: false, children: _jsx(NavigationMenuList, { className: cn("h-16 items-stretch gap-0", className), children: items.map((item, index) => "items" in item ? (_jsx(DropdownNavItem, { first: index === 0, item: item }, item.label)) : (_jsx(NavigationMenuItem, { className: "flex", children: _jsx(NavigationMenuLink, { active: isActive(item.href), asChild: true, className: topLevelItemClassName(index === 0), children: item.href.startsWith("http") ? (_jsxs("a", { className: "flex flex-row items-center gap-1", href: item.href, rel: "noopener", target: "_blank", children: [item.label, _jsx(IconArrowUpRightSmall, { "aria-hidden": "true", className: "will-change-transform", size: 12 })] })) : (_jsx(LocalizedLink, { href: item.href, children: item.label })) }) }, item.href))) }) }), _jsx("div", { "aria-hidden": "true", className: cn("pointer-events-none fixed inset-x-0 top-16 bottom-0 z-0 bg-background-200/60", navOpen ? "opacity-100" : "opacity-0") })] }));
52
+ return (_jsxs(_Fragment, { children: [_jsx(NavigationMenu, { "aria-label": "Primary navigation", delayDuration: 0, onValueChange: (value) => setNavOpen(Boolean(value)), skipDelayDuration: 0, viewport: false, children: _jsx(NavigationMenuList, { className: cn("h-16 items-stretch gap-0", className), children: items.map((item, index) => "items" in item ? (_jsx(DropdownNavItem, { first: index === 0, item: item }, item.label)) : (_jsx(NavigationMenuItem, { className: "flex", children: _jsx(NavigationMenuLink, { active: isActive(item.href), asChild: true, className: topLevelItemClassName(index === 0), children: item.href.startsWith("http") ? (_jsxs("a", { className: "flex flex-row items-center gap-1", href: item.href, rel: "noopener", target: "_blank", children: [item.label, _jsx(IconArrowUpRightSmall, { "aria-hidden": "true", className: cn(navOpen && "will-change-transform"), size: 12 })] })) : (_jsx(LocalizedLink, { href: item.href, children: item.label })) }) }, item.href))) }) }), _jsx("div", { "aria-hidden": "true", className: cn("pointer-events-none fixed inset-x-0 top-16 bottom-0 z-0 bg-background-200/60", navOpen ? "opacity-100" : "opacity-0") })] }));
53
53
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/mobile-menu.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,yBAAyB,EAEzB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAQtB,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,gBAAgB,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA6PD,eAAO,MAAM,UAAU,GAAI,0DAMxB,eAAe,4CAkIjB,CAAC"}
1
+ {"version":3,"file":"mobile-menu.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/mobile-menu.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,yBAAyB,EAEzB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAQtB,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,gBAAgB,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA6PD,eAAO,MAAM,UAAU,GAAI,0DAMxB,eAAe,4CA4HjB,CAAC"}
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { ThemeSwitcher } from "@vercel/geistcn/components/theme-switcher";
4
4
  import { cn } from "@vercel/geistcn/utils";
5
5
  import { IconChevronDownSmall } from "@vercel/geistcn-assets/icons";
6
+ import { useMediaQuery } from "phase/react";
6
7
  import { useEffect, useState } from "react";
7
8
  import { SearchButton } from "../../controls";
8
9
  import { ExternalArrow } from "../external-arrow";
@@ -50,9 +51,10 @@ function OssCollapsible({ sections, onLinkClick, }) {
50
51
  return (_jsxs("details", { className: "group flex flex-col", name: "geistdocs-mobile-nav", children: [_jsxs("summary", { className: "flex min-h-11 cursor-pointer list-none items-center justify-between rounded-md px-3 font-normal text-2xl text-gray-900 outline-none transition-colors hover:bg-gray-alpha-100 hover:text-gray-1000 [&::-webkit-details-marker]:hidden", children: [_jsxs("span", { children: ["Vercel OSS", _jsx(ExternalArrow, { className: "mt-1" })] }), _jsx(IconChevronDownSmall, { className: "relative shrink-0 text-gray-700 transition-transform duration-150 group-open:rotate-180", size: 24 })] }), _jsx("div", { className: "flex flex-col gap-6 px-3 py-4", children: sections.map((section) => (_jsxs("div", { className: "flex flex-col", children: [_jsx("p", { className: "mb-2 font-mono text-gray-700 text-xs uppercase tracking-wider", children: section.heading }), _jsx("ul", { className: "-mx-3 flex list-none flex-col", children: section.items.map((product) => (_jsx("li", { children: _jsx(SubNavLink, { external: product.external ?? product.href.startsWith("http"), href: product.href, onClick: onLinkClick, children: product.label }) }, product.href))) })] }, section.heading))) })] }));
51
52
  }
52
53
  function MobileMenuButton({ expanded, onClick, }) {
53
- return (_jsx("button", { "aria-expanded": expanded, "aria-label": expanded ? "Close menu" : "Open menu", className: "relative flex @min-[1024px]:hidden size-8 items-center justify-center rounded-full border border-gray-200 transition-colors hover:bg-gray-100", "data-slot": "mobile-menu-toggle", onClick: onClick, type: "button", children: _jsxs("span", { className: "flex flex-col items-center justify-center gap-[5px]", children: [_jsx("span", { className: cn("block h-[1.5px] w-3.5 bg-gray-1000 transition-all duration-150", expanded && "translate-y-[3.25px] rotate-45") }), _jsx("span", { className: cn("block h-[1.5px] w-3.5 bg-gray-1000 transition-all duration-150", expanded && "-translate-y-[3.25px] -rotate-45") })] }) }));
54
+ return (_jsx("button", { "aria-expanded": expanded, "aria-label": expanded ? "Close menu" : "Open menu", className: "relative flex @min-[1024px]:hidden size-8 items-center justify-center rounded-full border border-gray-200 transition-colors hover:bg-gray-100", "data-slot": "mobile-menu-toggle", onClick: onClick, type: "button", children: _jsxs("span", { className: "flex flex-col items-center justify-center gap-[5px]", children: [_jsx("span", { className: cn("block h-[1.5px] w-3.5 bg-gray-1000 transition-transform duration-150", expanded && "translate-y-[3.25px] rotate-45") }), _jsx("span", { className: cn("block h-[1.5px] w-3.5 bg-gray-1000 transition-transform duration-150", expanded && "-translate-y-[3.25px] -rotate-45") })] }) }));
54
55
  }
55
56
  export const MobileMenu = ({ activeProduct, githubUrl, nav, ossProducts, showOss = false, }) => {
57
+ const isDesktop = useMediaQuery("(min-width: 1024px)");
56
58
  const [show, setShow] = useState(false);
57
59
  const isActive = useNavActive();
58
60
  // Resolve the default/custom list and drop the active product here on the
@@ -83,18 +85,11 @@ export const MobileMenu = ({ activeProduct, githubUrl, nav, ossProducts, showOss
83
85
  useEffect(() => {
84
86
  setShow(false);
85
87
  }, []);
86
- // Close the sheet when resizing up to desktop (also releases the scroll lock).
87
88
  useEffect(() => {
88
- const mq = window.matchMedia("(min-width: 1024px)");
89
- const onChange = () => {
90
- if (mq.matches) {
91
- setShow(false);
92
- }
93
- };
94
- onChange();
95
- mq.addEventListener("change", onChange);
96
- return () => mq.removeEventListener("change", onChange);
97
- }, []);
89
+ if (isDesktop) {
90
+ setShow(false);
91
+ }
92
+ }, [isDesktop]);
98
93
  useEffect(() => {
99
94
  const handleEscape = (e) => {
100
95
  if (e.key === "Escape" && show) {
@@ -113,7 +108,7 @@ export const MobileMenu = ({ activeProduct, githubUrl, nav, ossProducts, showOss
113
108
  const close = () => setShow(false);
114
109
  return (_jsxs(_Fragment, { children: [_jsx(MobileMenuButton, { expanded: show, onClick: () => setShow(!show) }), _jsx("div", { className: cn("fixed inset-0 top-16 z-40 @min-[1024px]:hidden bg-background-200 transition-opacity duration-200", show
115
110
  ? "pointer-events-auto opacity-100"
116
- : "pointer-events-none opacity-0"), onClick: close }), _jsxs("div", { className: cn("fixed inset-x-0 top-16 bottom-0 z-40 @min-[1024px]:hidden overflow-y-auto bg-background-200 px-2 transition-all duration-200", show
111
+ : "pointer-events-none opacity-0"), onClick: close }), _jsxs("div", { className: cn("fixed inset-x-0 top-16 bottom-0 z-40 @min-[1024px]:hidden overflow-y-auto bg-background-200 px-2 transition-[transform,opacity] duration-200", show
117
112
  ? "translate-y-0 opacity-100"
118
113
  : "pointer-events-none -translate-y-2 opacity-0"), children: [_jsx("div", { className: "p-4", children: _jsx(SearchButton, { className: "w-full py-4.5", onClick: close }) }), _jsxs("nav", { className: "flex flex-col px-1", children: [nav.map((item) => "items" in item ? (_jsx(NavDropdownCollapsible, { dropdown: item, onLinkClick: close }, item.label)) : (_jsx(NavLink, { active: isActive(item.href), external: item.href.startsWith("http"), href: item.href, onClick: close, children: item.label }, item.href))), githubUrl ? (_jsx(NavLink, { external: true, href: githubUrl, onClick: close, children: "GitHub" })) : null, _jsx(OssCollapsible, { onLinkClick: close, sections: ossSections })] }), _jsx("div", { className: "mt-2 flex justify-end px-4 py-4", children: _jsx(ThemeSwitcher, { small: true }) })] })] }));
119
114
  };
@@ -1 +1 @@
1
- {"version":3,"file":"navbar-shell.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/navbar-shell.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAK5D,eAAO,MAAM,WAAW,GAAI,cAAc;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,4CAqBhE,CAAC"}
1
+ {"version":3,"file":"navbar-shell.d.ts","sourceRoot":"","sources":["../../../src/internal/navbar/navbar-shell.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAM5D,eAAO,MAAM,WAAW,GAAI,cAAc;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,4CAqBhE,CAAC"}
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { cn } from "@vercel/geistcn/utils";
4
4
  import { useEffect, useState } from "react";
5
+ import { MouseDownNavigation } from "../mousedown-navigation";
5
6
  // Sticky navbar shell that reveals its bottom divider (a box-shadow, so it
6
7
  // doesn't consume the 64px content row) only once the page is scrolled —
7
8
  // matching the vercel.com header.
@@ -13,5 +14,5 @@ export const NavbarShell = ({ children }) => {
13
14
  window.addEventListener("scroll", onScroll, { passive: true });
14
15
  return () => window.removeEventListener("scroll", onScroll);
15
16
  }, []);
16
- return (_jsx("header", { className: cn("sticky top-0 z-40 flex h-16 justify-center bg-background-200 transition-shadow motion-reduce:transition-none", scrolled && "shadow-[0_1px_0_0_var(--ds-gray-alpha-400)]"), "data-scrolled": scrolled ? "" : undefined, children: children }));
17
+ return (_jsx("header", { className: cn("sticky top-0 z-40 flex h-16 justify-center bg-background-200 transition-shadow motion-reduce:transition-none", scrolled && "shadow-[0_1px_0_0_var(--ds-gray-alpha-400)]"), "data-scrolled": scrolled ? "" : undefined, children: _jsx(MouseDownNavigation, { children: children }) }));
17
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAKL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAgBjD,UAAU,gBAAgB;IACxB,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CACxD,CAAC;IACF;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,UAAU,oCAAoC;IAC5C,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAC,CAAC;IACrE,YAAY,EAAE,SAAS,EAAE,CAAC;CAC3B;AAkpBD,eAAO,MAAM,oBAAoB,GAAI,yBAIlC,gBAAgB,mDAqHlB,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,2BAG7C,oCAAoC,4CAiBtC,CAAC"}
1
+ {"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAKL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAgBjD,UAAU,gBAAgB;IACxB,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CACxD,CAAC;IACF;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,UAAU,oCAAoC;IAC5C,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAC,CAAC;IACrE,YAAY,EAAE,SAAS,EAAE,CAAC;CAC3B;AAqrBD,eAAO,MAAM,oBAAoB,GAAI,yBAIlC,gBAAgB,mDAyGlB,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,2BAG7C,oCAAoC,4CAiBtC,CAAC"}
@@ -17,6 +17,26 @@ const actionClassName = "group flex min-h-8 w-full min-w-0 touch-manipulation it
17
17
  // Inline page-action link (icon + label) used in the mobile action row.
18
18
  const inlineActionClassName = "group flex touch-manipulation items-center gap-1.5 whitespace-nowrap text-gray-900 text-label-12 font-medium transition-colors hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-2 focus-visible:ring-offset-background-100 motion-reduce:transition-none [&_svg]:size-3.5 [&_svg]:shrink-0";
19
19
  const DEFAULT_EDIT_PATH = "content/docs/{path}";
20
+ const markdownRequests = new Map();
21
+ const getMarkdown = (url) => {
22
+ const cached = markdownRequests.get(url);
23
+ if (cached) {
24
+ return cached;
25
+ }
26
+ const request = fetch(url)
27
+ .then((response) => {
28
+ if (!response.ok) {
29
+ throw new Error(`Failed to fetch markdown from ${url}`);
30
+ }
31
+ return response.text();
32
+ })
33
+ .catch((error) => {
34
+ markdownRequests.delete(url);
35
+ throw error;
36
+ });
37
+ markdownRequests.set(url, request);
38
+ return request;
39
+ };
20
40
  const trimSlashes = (value) => value.replace(/^\/+|\/+$/g, "");
21
41
  const resolveEditPath = ({ editPath = DEFAULT_EDIT_PATH, path, }) => {
22
42
  const pagePath = trimSlashes(path);
@@ -153,18 +173,22 @@ const FeedbackAction = ({ siteId }) => {
153
173
  };
154
174
  // The mobile action row: three primary actions rendered inline below the
155
175
  // page description.
156
- const InlinePageActions = ({ askAIEnabled, checked, copyEnabled, onAskAI, onCopy, onViewMarkdown, }) => {
176
+ const InlinePageActions = ({ askAIEnabled, checked, copyEnabled, onAskAI, onCopy, onPrefetchMarkdown, onViewMarkdown, }) => {
157
177
  const CopyStateIcon = checked ? IconCheck : IconCopy;
158
- return (_jsxs("div", { className: "flex items-center gap-3 border-b pb-3 text-label-12", children: [copyEnabled ? (_jsxs(_Fragment, { children: [_jsxs("button", { className: inlineActionClassName, onClick: onCopy, type: "button", children: [_jsx(CopyStateIcon, {}), _jsx("span", { children: checked ? "Copied" : "Copy for LLM" })] }), _jsx("span", { "aria-hidden": "true", className: "h-4 w-px shrink-0 bg-gray-alpha-400 max-sm:hidden" }), _jsxs("button", { className: cn(inlineActionClassName, "max-sm:hidden"), onClick: onViewMarkdown, type: "button", children: [_jsx(IconAcronymMarkdown, { "aria-hidden": "true" }), _jsx("span", { children: "View Markdown" })] })] })) : null, copyEnabled && askAIEnabled ? (_jsx("span", { "aria-hidden": "true", className: "h-4 w-px shrink-0 bg-gray-alpha-400" })) : null, askAIEnabled ? (_jsxs("button", { className: inlineActionClassName, onClick: onAskAI, type: "button", children: [_jsx(IconMessage, {}), _jsx("span", { children: "Ask AI about this page" })] })) : null] }));
178
+ let copyLabel = "Copy for LLM";
179
+ if (checked) {
180
+ copyLabel = "Copied";
181
+ }
182
+ return (_jsxs("div", { className: "flex items-center gap-3 border-b pb-3 text-label-12", children: [copyEnabled ? (_jsxs(_Fragment, { children: [_jsxs("button", { className: inlineActionClassName, onClick: onCopy, onFocus: onPrefetchMarkdown, onPointerEnter: onPrefetchMarkdown, type: "button", children: [_jsx(CopyStateIcon, {}), _jsx("span", { children: copyLabel })] }), _jsx("span", { "aria-hidden": "true", className: "h-4 w-px shrink-0 bg-gray-alpha-400 max-sm:hidden" }), _jsxs("button", { className: cn(inlineActionClassName, "max-sm:hidden"), onClick: onViewMarkdown, type: "button", children: [_jsx(IconAcronymMarkdown, { "aria-hidden": "true" }), _jsx("span", { children: "View Markdown" })] })] })) : null, copyEnabled && askAIEnabled ? (_jsx("span", { "aria-hidden": "true", className: "h-4 w-px shrink-0 bg-gray-alpha-400" })) : null, askAIEnabled ? (_jsxs("button", { className: inlineActionClassName, onClick: onAskAI, type: "button", children: [_jsx(IconMessage, {}), _jsx("span", { children: "Ask AI about this page" })] })) : null] }));
159
183
  };
160
184
  // The desktop action control: a compact copy button plus an actions dropdown,
161
185
  // aligned beside the page title.
162
- const DesktopPageActions = ({ askAIEnabled, checked, copyEnabled, editSourceEnabled, editSourceUrl, isMobile, menuView, onAskAI, onCopy, onViewMarkdown, openInChatEnabled, openInChatRef, otherProviders, providersBackRef, query, setMenuView, v0Provider, }) => {
163
- return (_jsxs("div", { className: "inline-flex shrink-0 overflow-hidden rounded-md border border-gray-400 bg-background-100", children: [copyEnabled ? (_jsxs("button", { "aria-label": "Copy page", className: "inline-flex h-8 touch-manipulation items-center gap-1.5 px-3 font-medium text-sm transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50", onClick: onCopy, type: "button", children: [_jsxs("span", { className: "relative size-4", children: [_jsx(IconCopy, { className: cn("absolute inset-0 size-4 transition-all duration-200", checked ? "scale-75 opacity-0" : "scale-100 opacity-100") }), _jsx(IconCheck, { className: cn("absolute inset-0 size-4 transition-all duration-200", checked ? "scale-100 opacity-100" : "scale-75 opacity-0") })] }), _jsx("span", { children: "Copy page" })] })) : null, _jsxs(DropdownMenu, { onOpenChange: (open) => {
186
+ const DesktopPageActions = ({ askAIEnabled, checked, copyEnabled, editSourceEnabled, editSourceUrl, isMobile, menuView, onAskAI, onCopy, onPrefetchMarkdown, onViewMarkdown, openInChatEnabled, openInChatRef, otherProviders, providersBackRef, query, setMenuView, v0Provider, }) => {
187
+ return (_jsxs("div", { className: "inline-flex shrink-0 overflow-hidden rounded-md border border-gray-400 bg-background-100", children: [copyEnabled ? (_jsxs("button", { "aria-label": "Copy page", className: "inline-flex h-8 touch-manipulation items-center gap-1.5 whitespace-nowrap px-3 font-medium text-sm transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50", onClick: onCopy, onFocus: onPrefetchMarkdown, onPointerEnter: onPrefetchMarkdown, type: "button", children: [_jsxs("span", { className: "relative size-4", children: [_jsx(IconCopy, { className: cn("absolute inset-0 size-4 transition-[transform,opacity] duration-200", checked ? "scale-75 opacity-0" : "scale-100 opacity-100") }), _jsx(IconCheck, { className: cn("absolute inset-0 size-4 transition-[transform,opacity] duration-200", checked ? "scale-100 opacity-100" : "scale-75 opacity-0") })] }), _jsx("span", { children: "Copy page" })] })) : null, _jsxs(DropdownMenu, { onOpenChange: (open) => {
164
188
  if (!open) {
165
189
  setMenuView("main");
166
190
  }
167
- }, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { "aria-label": copyEnabled ? "Open page actions" : "Page actions", className: "inline-flex h-8 touch-manipulation items-center justify-center gap-1.5 border-gray-400 border-l px-2 transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50", type: "button", children: [copyEnabled ? null : _jsx("span", { children: "Page actions" }), _jsx(IconChevronDown, { className: "size-4" })] }) }), _jsx(DropdownMenuContent, { align: "end", className: "w-80 max-w-[calc(100vw-1rem)]", sideOffset: 8, children: isMobile && menuView === "providers" ? (_jsx(ProviderMenuView, { backRef: providersBackRef, onBack: () => {
191
+ }, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { "aria-label": copyEnabled ? "Open page actions" : "Page actions", className: "inline-flex h-8 touch-manipulation items-center justify-center gap-1.5 border-gray-400 border-l px-2 transition-colors hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50 data-[state=closed]:bg-transparent data-[state=open]:bg-gray-100 data-[state=closed]:hover:bg-gray-100", type: "button", children: [copyEnabled ? null : _jsx("span", { children: "Page actions" }), _jsx(IconChevronDown, { className: "size-4" })] }) }), _jsx(DropdownMenuContent, { align: "end", className: "w-80 max-w-[calc(100vw-1rem)]", sideOffset: 8, children: isMobile && menuView === "providers" ? (_jsx(ProviderMenuView, { backRef: providersBackRef, onBack: () => {
168
192
  setMenuView("main");
169
193
  requestAnimationFrame(() => openInChatRef.current?.focus());
170
194
  }, providers: otherProviders, query: query })) : (_jsx(PageActionsMainMenu, { askAIEnabled: askAIEnabled, copyEnabled: copyEnabled, editSourceEnabled: editSourceEnabled, editSourceUrl: editSourceUrl, handleCopy: onCopy, isMobile: isMobile, onAskAI: onAskAI, onShowProviders: () => {
@@ -174,41 +198,20 @@ const DesktopPageActions = ({ askAIEnabled, checked, copyEnabled, editSourceEnab
174
198
  };
175
199
  export const GeistdocsPageActions = ({ config, page, only, }) => {
176
200
  const isMobile = useIsMobile();
177
- const { enabled: chatEnabled, setIsOpen, setPrompt } = useGeistdocsChat();
201
+ const { enabled: chatEnabled, preloadChat, setIsOpen, setPrompt, } = useGeistdocsChat();
178
202
  const [menuView, setMenuView] = useState("main");
179
203
  const openInChatRef = useRef(null);
180
204
  const providersBackRef = useRef(null);
181
205
  const markdownUrl = page.markdownUrl;
182
- const fetchMarkdown = async () => {
183
- const response = await fetch(markdownUrl);
184
- if (!response.ok) {
185
- throw new Error(`Failed to fetch markdown from ${markdownUrl}`);
186
- }
187
- return await response.text();
206
+ const fetchMarkdown = () => getMarkdown(markdownUrl);
207
+ const prefetchMarkdown = () => {
208
+ getMarkdown(markdownUrl).catch(() => undefined);
188
209
  };
189
210
  const [checked, handleCopy] = useCopyButton(async () => {
190
211
  await navigator.clipboard.writeText(await fetchMarkdown());
191
212
  });
192
213
  const handleViewMarkdown = () => {
193
- // Open synchronously so popup blockers allow the tab, then load the
194
- // markdown into a blob URL — keeps `.md` URLs out of the address bar
195
- // and browser history (agents should cite canonical page URLs).
196
- const viewer = window.open("about:blank", "_blank");
197
- if (!viewer) {
198
- return;
199
- }
200
- fetchMarkdown()
201
- .then((markdown) => {
202
- const blob = new Blob([markdown], {
203
- type: "text/plain;charset=utf-8",
204
- });
205
- const blobUrl = URL.createObjectURL(blob);
206
- viewer.location.href = blobUrl;
207
- setTimeout(() => URL.revokeObjectURL(blobUrl), 60_000);
208
- })
209
- .catch(() => {
210
- viewer.close();
211
- });
214
+ window.open(markdownUrl, "_blank", "noopener");
212
215
  };
213
216
  const editSourceUrl = getEditSourceUrl({
214
217
  github: config.github,
@@ -229,13 +232,14 @@ export const GeistdocsPageActions = ({ config, page, only, }) => {
229
232
  const showDesktop = only !== "mobile";
230
233
  const showMobile = only !== "desktop";
231
234
  const onAskAI = () => {
235
+ preloadChat();
232
236
  setPrompt(getPageQuery(page.url, window.location.origin));
233
237
  setIsOpen(true);
234
238
  };
235
239
  // Desktop variant aligns beside the title (self-end); the mobile variant is
236
240
  // rendered below the description and left-aligned.
237
241
  const rootClassName = only === "mobile" ? "@min-[961px]:hidden" : "self-end @max-[960px]:hidden";
238
- return (_jsxs("div", { className: rootClassName, children: [showDesktop ? (_jsx(DesktopPageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, editSourceEnabled: editSourceEnabled, editSourceUrl: editSourceUrl, isMobile: isMobile, menuView: menuView, onAskAI: onAskAI, onCopy: handleCopy, onViewMarkdown: handleViewMarkdown, openInChatEnabled: openInChatEnabled, openInChatRef: openInChatRef, otherProviders: otherProviders, providersBackRef: providersBackRef, query: query, setMenuView: setMenuView, v0Provider: v0Provider })) : null, showMobile && (copyEnabled || askAIEnabled) ? (_jsx(InlinePageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, onAskAI: onAskAI, onCopy: handleCopy, onViewMarkdown: handleViewMarkdown })) : null, _jsx("span", { "aria-live": "polite", className: "sr-only", children: checked ? "Page copied" : "" })] }));
242
+ return (_jsxs("div", { className: rootClassName, onFocusCapture: preloadChat, onPointerEnter: preloadChat, children: [showDesktop ? (_jsx(DesktopPageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, editSourceEnabled: editSourceEnabled, editSourceUrl: editSourceUrl, isMobile: isMobile, menuView: menuView, onAskAI: onAskAI, onCopy: handleCopy, onPrefetchMarkdown: prefetchMarkdown, onViewMarkdown: handleViewMarkdown, openInChatEnabled: openInChatEnabled, openInChatRef: openInChatRef, otherProviders: otherProviders, providersBackRef: providersBackRef, query: query, setMenuView: setMenuView, v0Provider: v0Provider })) : null, showMobile && (copyEnabled || askAIEnabled) ? (_jsx(InlinePageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, onAskAI: onAskAI, onCopy: handleCopy, onPrefetchMarkdown: prefetchMarkdown, onViewMarkdown: handleViewMarkdown })) : null, _jsx("span", { "aria-live": "polite", className: "sr-only", children: checked ? "Page copied" : "" })] }));
239
243
  };
240
244
  export const GeistdocsTableOfContentsActions = ({ config, extraActions, }) => {
241
245
  const actions = [];
@@ -1 +1 @@
1
- {"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAQjD,MAAM,WAAW,sBACf,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA2CD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAQ9D,CAAC"}
1
+ {"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAcjD,MAAM,WAAW,sBACf,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAgFD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAQ9D,CAAC"}
@@ -4,21 +4,45 @@ import { Toasts } from "@vercel/geistcn/components/toasts";
4
4
  import { GeistProvider } from "@vercel/geistcn/core";
5
5
  import { cn } from "@vercel/geistcn/utils";
6
6
  import { RootProvider } from "fumadocs-ui/provider/next";
7
- import { useCallback } from "react";
7
+ import { lazy, Suspense, useCallback, useEffect, } from "react";
8
8
  import { GeistdocsChatProvider, useGeistdocsChat } from "./chat/context";
9
- import { GeistdocsChatShell } from "./chat/shell";
9
+ import { ChatLoadingSkeleton } from "./chat/loading-skeleton";
10
10
  import { GeistdocsConfigProvider } from "./config-context";
11
11
  import { createGeistdocsI18n } from "./i18n";
12
12
  import { GeistdocsSearchDialog } from "./search";
13
13
  import { useIsMobile } from "./use-mobile";
14
+ const GeistdocsChatShell = lazy(() => import("./chat/shell").then(({ GeistdocsChatShell: Component }) => ({
15
+ default: Component,
16
+ })));
14
17
  const GeistdocsProviderInner = ({ config, search, theme: _theme, lang, ...props }) => {
15
18
  const { i18n, i18nProvider } = createGeistdocsI18n(config);
16
- const { enabled, isOpen } = useGeistdocsChat();
19
+ const { enabled, hasBeenOpened, isOpen, setIsOpen } = useGeistdocsChat();
17
20
  const isMobile = useIsMobile();
21
+ useEffect(() => {
22
+ if (!enabled) {
23
+ return;
24
+ }
25
+ const handleKeyDown = (event) => {
26
+ if (event.key === "Escape" && isOpen) {
27
+ event.preventDefault();
28
+ setIsOpen(false);
29
+ return;
30
+ }
31
+ if ((event.metaKey || event.ctrlKey) &&
32
+ !event.altKey &&
33
+ !event.shiftKey &&
34
+ event.key.toLowerCase() === "i") {
35
+ event.preventDefault();
36
+ setIsOpen((open) => !open);
37
+ }
38
+ };
39
+ document.addEventListener("keydown", handleKeyDown, true);
40
+ return () => document.removeEventListener("keydown", handleKeyDown, true);
41
+ }, [enabled, isOpen, setIsOpen]);
18
42
  const SearchDialogComponent = useCallback((searchProps) => (_jsx(GeistdocsSearchDialog, { basePath: config.basePath, ...searchProps })), [config.basePath]);
19
43
  return (_jsxs("div", { className: cn("@container transition-[padding-right] duration-150 ease-[cubic-bezier(0.175,0.885,0.32,1.1)] motion-reduce:transition-none", enabled && isOpen && !isMobile ? "pr-[400px]!" : null), "data-geistdocs-container": true, children: [_jsx(RootProvider, { i18n: i18nProvider(lang ?? i18n.defaultLanguage), search: {
20
44
  SearchDialog: SearchDialogComponent,
21
45
  ...search,
22
- }, theme: { enabled: false }, ...props }), _jsx(Toasts, {}), _jsx(GeistdocsChatShell, {})] }));
46
+ }, theme: { enabled: false }, ...props }), _jsx(Toasts, {}), hasBeenOpened ? (_jsx(Suspense, { fallback: isOpen ? (_jsx(ChatLoadingSkeleton, { isMobile: isMobile, title: config.title })) : null, children: _jsx(GeistdocsChatShell, {}) })) : null] }));
23
47
  };
24
- export const GeistdocsProvider = (props) => (_jsx(GeistProvider, { storageKey: "geistdocs-theme", children: _jsx(GeistdocsConfigProvider, { config: props.config, children: _jsx(GeistdocsChatProvider, { config: props.config, children: _jsx(GeistdocsProviderInner, { ...props }) }) }) }));
48
+ export const GeistdocsProvider = (props) => (_jsx(GeistProvider, { storageKey: "geistdocs-theme", withScript: false, children: _jsx(GeistdocsConfigProvider, { config: props.config, children: _jsx(GeistdocsChatProvider, { config: props.config, children: _jsx(GeistdocsProviderInner, { ...props }) }) }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/internal/search.tsx"],"names":[],"mappings":"AAGA,OAAO,EAUL,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAC;AAI9C,eAAO,MAAM,qBAAqB,GAAI,wBAGnC,WAAW,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,4CAoCrC,CAAC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/internal/search.tsx"],"names":[],"mappings":"AAGA,OAAO,EAUL,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAC;AAI9C,eAAO,MAAM,qBAAqB,GAAI,wBAGnC,WAAW,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,4CAwCrC,CAAC"}
@@ -11,5 +11,5 @@ export const GeistdocsSearchDialog = ({ basePath, ...props }) => {
11
11
  locale,
12
12
  api: getPublicPath("/api/search", basePath),
13
13
  });
14
- return (_jsxs(FumadocsSearchDialog, { isLoading: query.isLoading, onSearchChange: setSearch, search: search, ...props, children: [_jsx(SearchDialogOverlay, { className: "bg-background-100/80 backdrop-blur-none" }), _jsxs(SearchDialogContent, { className: "border-none", "data-geistdocs-command-modal": true, children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { "aria-label": "Search results", Item: (itemProps) => (_jsx(SearchDialogListItem, { ...itemProps, role: "option" })), items: query.data === "empty" ? null : query.data, role: "listbox" })] })] }));
14
+ return (_jsxs(FumadocsSearchDialog, { isLoading: query.isLoading, onSearchChange: setSearch, search: search, ...props, children: [_jsx(SearchDialogOverlay, { className: "bg-background-100/80 backdrop-blur-none" }), _jsxs(SearchDialogContent, { className: "border-none", "data-geistdocs-command-modal": true, onEscapeKeyDown: () => props.onOpenChange(false), children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { "aria-label": "Search results", Item: (itemProps) => (_jsx(SearchDialogListItem, { ...itemProps, role: "option" })), items: query.data === "empty" ? null : query.data, role: "listbox" })] })] }));
15
15
  };
@@ -1,3 +1,2 @@
1
1
  export declare const SIDEBAR_DESKTOP_MIN_WIDTH = 961;
2
- export declare const observeSidebarContainer: (container: Element, onDesktop: () => void) => (() => void);
3
2
  //# sourceMappingURL=sidebar-responsive.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar-responsive.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar-responsive.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,eAAO,MAAM,uBAAuB,GAClC,WAAW,OAAO,EAClB,WAAW,MAAM,IAAI,KACpB,CAAC,MAAM,IAAI,CASb,CAAC"}
1
+ {"version":3,"file":"sidebar-responsive.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar-responsive.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,MAAM,CAAC"}
@@ -1,10 +1 @@
1
1
  export const SIDEBAR_DESKTOP_MIN_WIDTH = 961;
2
- export const observeSidebarContainer = (container, onDesktop) => {
3
- const resizeObserver = new ResizeObserver(([entry]) => {
4
- if (entry && entry.contentRect.width >= SIDEBAR_DESKTOP_MIN_WIDTH) {
5
- onDesktop();
6
- }
7
- });
8
- resizeObserver.observe(container);
9
- return () => resizeObserver.disconnect();
10
- };
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,oBAAoB,EAAuB,MAAM,YAAY,CAAC;AA85B5E,eAAO,MAAM,gBAAgB,GAAI,6BAI9B;IACD,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB,4CA+DA,CAAC"}
1
+ {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/internal/sidebar.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,oBAAoB,EAAuB,MAAM,YAAY,CAAC;AAk9B5E,eAAO,MAAM,gBAAgB,GAAI,6BAI9B;IACD,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB,4CAiEA,CAAC"}