@vercel/geistdocs 1.12.0 → 1.13.0

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 (53) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/controls.d.ts.map +1 -1
  3. package/dist/controls.js +7 -5
  4. package/dist/home-layout.d.ts.map +1 -1
  5. package/dist/home-layout.js +2 -7
  6. package/dist/internal/page-actions-client.js +1 -1
  7. package/dist/internal/provider-client.d.ts.map +1 -1
  8. package/dist/internal/provider-client.js +1 -1
  9. package/dist/internal/sidebar-responsive.d.ts +3 -0
  10. package/dist/internal/sidebar-responsive.d.ts.map +1 -0
  11. package/dist/internal/sidebar-responsive.js +10 -0
  12. package/dist/internal/sidebar-tree.d.ts +23 -0
  13. package/dist/internal/sidebar-tree.d.ts.map +1 -0
  14. package/dist/internal/sidebar-tree.js +115 -0
  15. package/dist/internal/sidebar.d.ts +2 -5
  16. package/dist/internal/sidebar.d.ts.map +1 -1
  17. package/dist/internal/sidebar.js +282 -44
  18. package/dist/internal/table-of-contents.js +1 -1
  19. package/dist/internal/ui/sheet.d.ts.map +1 -1
  20. package/dist/internal/ui/sheet.js +2 -2
  21. package/dist/layout.d.ts.map +1 -1
  22. package/dist/layout.js +1 -6
  23. package/dist/mdx.d.ts +1 -0
  24. package/dist/mdx.d.ts.map +1 -1
  25. package/dist/mobile-docs-bar.d.ts.map +1 -1
  26. package/dist/mobile-docs-bar.js +3 -3
  27. package/dist/navbar.js +1 -1
  28. package/dist/pages/docs.js +1 -1
  29. package/dist/source-config.d.ts +1 -0
  30. package/dist/source-config.d.ts.map +1 -1
  31. package/dist/source-config.js +1 -0
  32. package/dist/source.d.ts +1 -0
  33. package/dist/source.d.ts.map +1 -1
  34. package/dist/source.js +21 -2
  35. package/dist/versions.d.ts.map +1 -1
  36. package/dist/versions.js +3 -3
  37. package/docs/agents.md +2 -2
  38. package/docs/llms.txt +197 -30
  39. package/docs/manifest.json +10 -9
  40. package/docs/pages/configuration.md +3 -0
  41. package/docs/pages/getting-started.md +2 -0
  42. package/docs/pages/guides/nested-navigation.md +174 -13
  43. package/docs/pages/syntax.md +2 -1
  44. package/docs/sitemap.md +1 -1
  45. package/package.json +1 -1
  46. package/source-config.js +1 -0
  47. package/template/app/styles/geistdocs.css +8 -6
  48. package/template/content/docs/configuration.mdx +3 -0
  49. package/template/content/docs/getting-started.mdx +2 -0
  50. package/template/content/docs/guides/nested-navigation.mdx +174 -12
  51. package/template/content/docs/syntax.mdx +2 -1
  52. package/template/package.json +1 -1
  53. package/theme.css +150 -0
@@ -1,20 +1,19 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { searchPath } from "fumadocs-core/breadcrumb";
4
- import { SidebarFolder, SidebarFolderContent, SidebarFolderLink, SidebarFolderTrigger, SidebarItem, SidebarSeparator, } from "fumadocs-ui/components/sidebar/base";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import Link from "fumadocs-core/link";
5
4
  import { useTreeContext } from "fumadocs-ui/contexts/tree";
5
+ import { ArrowUpRightIcon } from "lucide-react";
6
6
  import { useParams, usePathname } from "next/navigation";
7
- import { createContext, Fragment, useContext, useEffect, useMemo, useRef, } from "react";
7
+ import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from "react";
8
+ import { IconChevronDownSmall } from "../assets/icons/icon-chevron-down-small";
9
+ import { IconChevronRight } from "../assets/icons/icon-chevron-right";
8
10
  import { SearchButton } from "../controls";
9
11
  import { useGeistdocsSidebar } from "../sidebar";
12
+ import { cn } from "./cn";
13
+ import { observeSidebarContainer } from "./sidebar-responsive";
14
+ import { findActiveRootSection, getDescendantFolderIds, getInitialOpenFolderIds, getSidebarItemBadge, getSidebarNodeId, getSidebarRootGroups, getSidebarSectionItems, hasSeparateRootDisclosure, isExternalSidebarItem, isExternalSidebarUrl, } from "./sidebar-tree";
10
15
  import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "./ui/sheet";
11
- /**
12
- * Ancestors of the active page, from route params instead of `usePathname()`
13
- * (empty during static prerender, so fumadocs' `useTreePath()` leaves the
14
- * active folder collapsed until hydration — shifting the sidebar). Params
15
- * resolve at prerender, keeping the active section open in the initial HTML.
16
- */
17
- const SidebarActivePathContext = createContext([]);
16
+ const UNSAFE_ID_CHARACTERS = /[^a-zA-Z0-9_-]/g;
18
17
  const collectPageUrls = (nodes) => {
19
18
  const urls = [];
20
19
  for (const node of nodes) {
@@ -30,12 +29,19 @@ const collectPageUrls = (nodes) => {
30
29
  }
31
30
  return urls;
32
31
  };
32
+ const findShortestPageUrl = (nodes) => {
33
+ let shortest;
34
+ for (const url of collectPageUrls(nodes)) {
35
+ if (!shortest || url.length < shortest.length) {
36
+ shortest = url;
37
+ }
38
+ }
39
+ return shortest;
40
+ };
33
41
  /**
34
- * The active page's URL, found by matching the slug as a URL suffix rather than
35
- * rebuilding it from a mount base — the base isn't reliably derivable from the
36
- * tree (a site with all pages under one folder has no shared top-level prefix).
37
- * The shallowest suffix match is the active page: any deeper match belongs to a
38
- * page with a longer slug, so it can't be the one these params point to.
42
+ * Match route params to a page-tree URL without assuming a docs mount point.
43
+ * Params resolve during prerender, keeping the active section open before
44
+ * hydration even when `usePathname()` is not yet available to Fumadocs.
39
45
  */
40
46
  const findActiveUrl = (nodes, slug) => {
41
47
  if (!slug) {
@@ -47,47 +53,279 @@ const findActiveUrl = (nodes, slug) => {
47
53
  .sort((a, b) => a.split("/").length - b.split("/").length)
48
54
  .at(0);
49
55
  };
50
- export const GeistdocsSidebar = ({ top }) => {
56
+ const findActiveUrlFromPathname = (nodes, pathname) => collectPageUrls(nodes)
57
+ .filter((url) => pathname === url || pathname.endsWith(url))
58
+ .sort((a, b) => b.length - a.length)
59
+ .at(0);
60
+ const opensOutsideCurrentPage = (event, external, href) => Boolean(external ||
61
+ isExternalSidebarUrl(href) ||
62
+ event.button !== 0 ||
63
+ event.metaKey ||
64
+ event.ctrlKey ||
65
+ event.shiftKey ||
66
+ event.altKey);
67
+ const getDomId = (prefix, id) => `${prefix}-${id.replace(UNSAFE_ID_CHARACTERS, "-")}`;
68
+ const getRootDisclosureLabel = (name) => typeof name === "string" || typeof name === "number"
69
+ ? `Browse ${name}`
70
+ : "Browse Section";
71
+ const scrollItemIntoView = (scrollContainer, item) => {
72
+ const containerRect = scrollContainer.getBoundingClientRect();
73
+ const itemRect = item.getBoundingClientRect();
74
+ const fullyVisible = itemRect.top >= containerRect.top &&
75
+ itemRect.bottom <= containerRect.bottom;
76
+ if (fullyVisible) {
77
+ return;
78
+ }
79
+ const offsetTop = itemRect.top - containerRect.top + scrollContainer.scrollTop;
80
+ const centered = offsetTop - (scrollContainer.clientHeight - itemRect.height) / 2;
81
+ const maxScrollTop = scrollContainer.scrollHeight - scrollContainer.clientHeight;
82
+ scrollContainer.scrollTo({
83
+ behavior: "auto",
84
+ top: Math.min(Math.max(centered, 0), maxScrollTop),
85
+ });
86
+ };
87
+ const useActiveItemScroll = (contentRef, activeKey, enabled, stateKey) => {
88
+ const updateKey = `${activeKey ?? ""}:${stateKey}`;
89
+ useLayoutEffect(() => {
90
+ const content = contentRef.current;
91
+ if (!(content && enabled && updateKey)) {
92
+ return;
93
+ }
94
+ const scrollContainer = content.closest("[data-geistdocs-sidebar-scroll]");
95
+ const activeItem = content.querySelector('[aria-current="page"], [data-sidebar-active="true"]');
96
+ if (scrollContainer && activeItem) {
97
+ scrollItemIntoView(scrollContainer, activeItem);
98
+ }
99
+ }, [contentRef, enabled, updateKey]);
100
+ };
101
+ const useOpenedFolders = (nodes, activeUrl, openFirstLevel, scope) => {
102
+ const desiredOpenIds = useMemo(() => getInitialOpenFolderIds(nodes, activeUrl, openFirstLevel, scope), [activeUrl, nodes, openFirstLevel, scope]);
103
+ const [opened, setOpened] = useState(desiredOpenIds);
104
+ useLayoutEffect(() => {
105
+ setOpened((current) => {
106
+ const next = [...new Set([...current, ...desiredOpenIds])];
107
+ return next.length === current.length ? current : next;
108
+ });
109
+ }, [desiredOpenIds]);
110
+ const toggleFolder = (folder, path) => {
111
+ const id = getSidebarNodeId(folder, path, scope);
112
+ setOpened((current) => {
113
+ if (!current.includes(id)) {
114
+ return [...current, id];
115
+ }
116
+ const closing = new Set([
117
+ id,
118
+ ...getDescendantFolderIds(folder, path, scope),
119
+ ]);
120
+ return current.filter((openId) => !closing.has(openId));
121
+ });
122
+ };
123
+ return { opened, toggleFolder };
124
+ };
125
+ const SidebarSeparatorRow = ({ depth, item, }) => (_jsxs("li", { className: cn("mt-4 flex items-center gap-2 px-2 pt-2 pb-1 text-gray-900 text-label-13 first:mt-0 [&_svg]:size-4", depth > 0 && "ml-3"), children: [item.icon ? _jsx("span", { className: "shrink-0", children: item.icon }) : null, _jsx("span", { className: "min-w-0 truncate", children: item.name })] }));
126
+ const SidebarTreeItems = ({ depth, nodes, parentPath, state, }) => (_jsx(_Fragment, { children: nodes.map((node, index) => (_jsx(SidebarTreeNode, { depth: depth, node: node, path: [...parentPath, index], state: state }, getSidebarNodeId(node, [...parentPath, index], state.idScope)))) }));
127
+ const getSidebarRowTone = (isSelected, isGroup) => {
128
+ if (isSelected) {
129
+ return "bg-gray-200 text-gray-1000 active:bg-gray-300";
130
+ }
131
+ if (isGroup) {
132
+ return "text-gray-1000 hover:bg-gray-alpha-100 focus-visible:bg-gray-alpha-100 active:bg-gray-alpha-300";
133
+ }
134
+ return "text-gray-900 hover:bg-gray-alpha-100 hover:text-gray-1000 focus-visible:bg-gray-alpha-100 focus-visible:text-gray-1000 active:bg-gray-alpha-300";
135
+ };
136
+ const SidebarDisclosureIcon = ({ expanded }) => (_jsx(_Fragment, { children: expanded ? (_jsx(IconChevronDownSmall, { size: 16 })) : (_jsx(IconChevronRight, { size: 16 })) }));
137
+ const SidebarBadge = ({ label }) => label ? (_jsx("span", { className: "inline-flex h-6 max-w-24 shrink-0 items-center truncate rounded-full bg-blue-100 px-2 text-blue-900 text-button-12", children: label })) : null;
138
+ const SidebarTreeNode = ({ depth, node, path, state, }) => {
139
+ const nodeId = getSidebarNodeId(node, path, state.idScope);
140
+ if (node.type === "separator") {
141
+ return _jsx(SidebarSeparatorRow, { depth: depth, item: node });
142
+ }
143
+ const folder = node.type === "folder" ? node : null;
144
+ const item = node.type === "folder" ? node.index : node;
145
+ const badge = getSidebarItemBadge(item);
146
+ const hasChildren = Boolean(folder?.children.length);
147
+ const isExpanded = Boolean(folder && state.opened.includes(nodeId));
148
+ const isSelected = item?.url === state.activeUrl;
149
+ const isGroup = depth === 0;
150
+ const menuId = getDomId(state.idPrefix, nodeId);
151
+ const labelId = `${menuId}-label`;
152
+ const rowClassName = cn("flex h-9 origin-left touch-manipulation flex-row items-center rounded-md pr-1 pl-2.5 transition-colors motion-reduce:transition-none", getSidebarRowTone(isSelected, isGroup));
153
+ const content = (_jsxs(_Fragment, { children: [node.icon ? (_jsx("span", { className: "shrink-0 [&_svg]:size-4", children: node.icon })) : null, _jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-1.5 truncate text-button-14", children: [_jsx("span", { className: "min-w-0 flex-1 truncate", id: labelId, children: node.name }), _jsx(SidebarBadge, { label: badge }), isExternalSidebarItem(item) ? (_jsx(ArrowUpRightIcon, { className: "ml-auto size-4 shrink-0 text-gray-900" })) : null] })] }));
154
+ const handleLinkClick = (event) => {
155
+ state.onNavigate?.();
156
+ if (opensOutsideCurrentPage(event, item?.external, item?.url ?? "") ||
157
+ !(folder && hasChildren && (isSelected || !isExpanded))) {
158
+ return;
159
+ }
160
+ state.toggleFolder(folder, path);
161
+ };
162
+ let primaryControl;
163
+ if (item) {
164
+ primaryControl = (_jsx(Link, { "aria-current": isSelected ? "page" : undefined, className: cn(rowClassName, "min-w-0 flex-1 no-underline outline-none focus-visible:shadow-[var(--ds-focus-ring)]"), external: item.external, href: item.url, onClick: handleLinkClick, children: content }));
165
+ }
166
+ else if (folder && hasChildren) {
167
+ primaryControl = (_jsxs("button", { "aria-controls": menuId, "aria-expanded": isExpanded, className: cn(rowClassName, "w-full min-w-0 flex-1 cursor-pointer border-0 bg-transparent text-left outline-none focus-visible:shadow-[var(--ds-focus-ring)]"), onClick: () => state.toggleFolder(folder, path), type: "button", children: [content, _jsx("span", { className: "grid size-8 flex-none place-content-center text-gray-900", children: _jsx(SidebarDisclosureIcon, { expanded: isExpanded }) })] }));
168
+ }
169
+ else {
170
+ primaryControl = (_jsx("span", { className: cn(rowClassName, "min-w-0 flex-1"), children: content }));
171
+ }
172
+ return (_jsxs("li", { className: cn("relative flex w-full select-none flex-col items-stretch", depth > 0 && "pl-3"), children: [_jsxs("div", { className: "relative flex w-full items-center gap-px", children: [primaryControl, item && folder && hasChildren ? (_jsx("button", { "aria-controls": menuId, "aria-expanded": isExpanded, "aria-labelledby": labelId, className: "grid size-8 flex-none cursor-pointer touch-manipulation place-content-center rounded-md bg-transparent p-0 text-gray-900 transition-colors hover:bg-gray-alpha-100 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:bg-gray-alpha-300 motion-reduce:transition-none", onClick: () => state.toggleFolder(folder, path), type: "button", children: _jsx(SidebarDisclosureIcon, { expanded: isExpanded }) })) : null] }), folder && hasChildren && isExpanded ? (_jsx("ul", { className: "relative mt-px mb-1 flex w-full list-none flex-col gap-px p-0", id: menuId, children: _jsx(SidebarTreeItems, { depth: depth + 1, nodes: folder.children, parentPath: path, state: state }) })) : null] }));
173
+ };
174
+ const SidebarTree = ({ activeUrl, idScope, nodes, onNavigate, openFirstLevel = false, scrollActive = false, visible = true, }) => {
175
+ const generatedId = useId().replace(UNSAFE_ID_CHARACTERS, "");
176
+ const resolvedIdScope = idScope ?? `sidebar-${generatedId}`;
177
+ const listRef = useRef(null);
178
+ const { opened, toggleFolder } = useOpenedFolders(nodes, activeUrl, openFirstLevel, resolvedIdScope);
179
+ const state = {
180
+ activeUrl,
181
+ idPrefix: `sidebar-${generatedId}`,
182
+ idScope: resolvedIdScope,
183
+ onNavigate,
184
+ opened,
185
+ toggleFolder,
186
+ };
187
+ useActiveItemScroll(listRef, activeUrl, scrollActive && visible, opened.join(":"));
188
+ return (_jsx("ul", { className: "m-0 flex list-none flex-col gap-px p-0", ref: listRef, children: _jsx(SidebarTreeItems, { depth: 0, nodes: nodes, parentPath: [], state: state }) }));
189
+ };
190
+ const SidebarRootList = ({ activeSection, activeUrl, groups, onSelect, visible, }) => {
191
+ const contentRef = useRef(null);
192
+ useActiveItemScroll(contentRef, activeUrl, visible, activeSection?.$id ?? "root");
193
+ return (_jsx("div", { className: "flex flex-col gap-4 px-2 pt-1 pb-2", ref: contentRef, children: groups.map((group) => (_jsxs("div", { className: "flex flex-col", children: [group.label || group.icon ? (_jsxs("div", { className: "flex items-center gap-2 px-2 pt-2 pb-1 text-gray-900 text-label-13 [&_svg]:size-4", children: [group.icon ? (_jsx("span", { className: "shrink-0", children: group.icon })) : null, _jsx("span", { className: "min-w-0 truncate", children: group.label })] })) : null, _jsx("ul", { className: "m-0 flex list-none flex-col gap-px p-0", children: group.items.map((section, index) => (_jsx(SidebarRootItem, { activeSection: activeSection, activeUrl: activeUrl, item: section, onSelect: onSelect }, getSidebarNodeId(section, [index])))) })] }, group.id))) }));
194
+ };
195
+ const SidebarRootItem = ({ activeSection, activeUrl, item, onSelect, }) => {
196
+ const folder = item.type === "folder" ? item : null;
197
+ const linkItem = item.type === "folder" ? item.index : item;
198
+ const badge = getSidebarItemBadge(linkItem);
199
+ const opensSection = Boolean(folder?.children.length);
200
+ const separateDisclosure = hasSeparateRootDisclosure(item);
201
+ const isCurrentPage = linkItem?.url === activeUrl;
202
+ const isActive = item === activeSection || isCurrentPage;
203
+ const className = cn("flex h-9 touch-manipulation items-center gap-2 rounded-md pr-2 pl-2.5 no-underline outline-none transition-colors focus-visible:shadow-[var(--ds-focus-ring)] motion-reduce:transition-none", isActive
204
+ ? "bg-gray-200 text-gray-1000 active:bg-gray-300"
205
+ : "text-gray-900 hover:bg-gray-alpha-100 hover:text-gray-1000 active:bg-gray-alpha-300");
206
+ const content = (_jsxs(_Fragment, { children: [item.icon ? (_jsx("span", { className: "shrink-0 [&_svg]:size-4", children: item.icon })) : null, _jsx("span", { className: "min-w-0 flex-1 truncate text-button-14", children: item.name }), _jsx(SidebarBadge, { label: badge }), isExternalSidebarItem(linkItem) ? (_jsx(ArrowUpRightIcon, { className: "size-4 shrink-0 text-gray-900" })) : null, opensSection && !separateDisclosure ? (_jsx(IconChevronRight, { className: "shrink-0 text-gray-900", size: 16 })) : null] }));
207
+ let renderedItem;
208
+ if (linkItem) {
209
+ renderedItem = (_jsx(Link, { "aria-current": isCurrentPage ? "page" : undefined, className: cn(className, separateDisclosure && "min-w-0 flex-1"), "data-sidebar-active": isActive, external: linkItem.external, href: linkItem.url, onClick: folder && opensSection
210
+ ? (event) => {
211
+ if (!opensOutsideCurrentPage(event, linkItem.external, linkItem.url)) {
212
+ onSelect(folder, event.currentTarget);
213
+ }
214
+ }
215
+ : undefined, children: content }));
216
+ }
217
+ else if (folder && opensSection) {
218
+ renderedItem = (_jsx("button", { className: cn(className, "w-full cursor-pointer border-0 bg-transparent text-left"), "data-sidebar-active": isActive, onClick: (event) => onSelect(folder, event.currentTarget), type: "button", children: content }));
219
+ }
220
+ else {
221
+ renderedItem = _jsx("span", { className: className, children: content });
222
+ }
223
+ return (_jsxs("li", { className: cn(separateDisclosure && "flex items-center gap-px"), children: [renderedItem, separateDisclosure ? (_jsx("button", { "aria-label": getRootDisclosureLabel(item.name), className: "grid size-8 flex-none cursor-pointer touch-manipulation place-content-center rounded-md bg-transparent p-0 text-gray-900 transition-colors hover:bg-gray-alpha-100 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:bg-gray-alpha-300 motion-reduce:transition-none", onClick: (event) => onSelect(item, event.currentTarget), type: "button", children: _jsx(IconChevronRight, { size: 16 }) })) : null] }));
224
+ };
225
+ const SidebarSectionHeader = ({ buttonRef, onBack, section, }) => (_jsx("div", { className: "mb-2 px-2 pt-1", children: _jsxs("button", { "aria-label": "Back to all documentation sections", className: "flex w-full cursor-pointer touch-manipulation flex-row items-center justify-between gap-1 rounded-md border-0 bg-transparent p-0 text-gray-900 transition-colors hover:bg-gray-alpha-100 hover:text-gray-1000 focus-visible:bg-gray-alpha-100 focus-visible:text-gray-1000 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:bg-gray-alpha-300 motion-reduce:transition-none", onClick: onBack, ref: buttonRef, type: "button", children: [_jsx("span", { className: "grid size-9 flex-none place-content-center", children: _jsx(IconChevronRight, { className: "rotate-180", size: 16 }) }), _jsx("span", { className: "flex min-w-0 flex-1 items-center justify-center text-button-14", children: _jsx("span", { className: "truncate", children: section.name }) }), _jsx("span", { className: "size-9 flex-none" })] }) }));
226
+ const DesktopSidebar = ({ activeUrl, nodes, rootScope, top, }) => {
227
+ const groups = useMemo(() => getSidebarRootGroups(nodes), [nodes]);
228
+ const currentSection = useMemo(() => findActiveRootSection(nodes, activeUrl), [activeUrl, nodes]);
229
+ const [selectedSection, setSelectedSection] = useState(null);
230
+ const activeSection = selectedSection ?? currentSection;
231
+ const [view, setView] = useState(currentSection ? "section" : "root");
232
+ const [sectionRevealed, setSectionRevealed] = useState(view === "section");
233
+ const navRef = useRef(null);
234
+ const returnFocusRef = useRef(null);
235
+ const sectionHeaderRef = useRef(null);
236
+ const shouldFocusRootRef = useRef(false);
237
+ const shouldFocusSectionRef = useRef(false);
238
+ const sectionItems = useMemo(() => getSidebarSectionItems(activeSection), [activeSection]);
239
+ const sectionScope = activeSection
240
+ ? getSidebarNodeId(activeSection, [Math.max(nodes.indexOf(activeSection), 0)], rootScope)
241
+ : rootScope;
242
+ useEffect(() => {
243
+ setSelectedSection(null);
244
+ setView(currentSection ? "section" : "root");
245
+ }, [currentSection]);
246
+ useEffect(() => {
247
+ if (view !== "section") {
248
+ setSectionRevealed(false);
249
+ return;
250
+ }
251
+ const frame = requestAnimationFrame(() => setSectionRevealed(true));
252
+ return () => cancelAnimationFrame(frame);
253
+ }, [view]);
254
+ useEffect(() => {
255
+ const nav = navRef.current;
256
+ if (!nav) {
257
+ return;
258
+ }
259
+ const updateFades = () => {
260
+ nav.dataset.fadeTop = String(nav.scrollTop > 0);
261
+ nav.dataset.fadeBottom = String(nav.scrollTop + nav.clientHeight < nav.scrollHeight - 1);
262
+ };
263
+ const resizeObserver = new ResizeObserver(updateFades);
264
+ updateFades();
265
+ nav.addEventListener("scroll", updateFades, { passive: true });
266
+ resizeObserver.observe(nav);
267
+ return () => {
268
+ nav.removeEventListener("scroll", updateFades);
269
+ resizeObserver.disconnect();
270
+ };
271
+ }, []);
272
+ const sectionShown = view === "section" && sectionRevealed;
273
+ const rootHidden = sectionShown;
274
+ const sectionHidden = !sectionShown;
275
+ useLayoutEffect(() => {
276
+ if (sectionShown && shouldFocusSectionRef.current) {
277
+ sectionHeaderRef.current?.focus({ preventScroll: true });
278
+ shouldFocusSectionRef.current = false;
279
+ return;
280
+ }
281
+ if (!sectionShown && shouldFocusRootRef.current) {
282
+ const returnTarget = returnFocusRef.current?.isConnected
283
+ ? returnFocusRef.current
284
+ : (navRef.current?.querySelector('[data-sidebar-pane="root"] [data-sidebar-active="true"]') ??
285
+ navRef.current?.querySelector('[data-sidebar-pane="root"] a, [data-sidebar-pane="root"] button'));
286
+ returnTarget?.focus({ preventScroll: true });
287
+ shouldFocusRootRef.current = false;
288
+ }
289
+ }, [sectionShown]);
290
+ return (_jsx("div", { className: "pointer-events-none sticky top-(--fd-docs-row-1) z-20 @min-[961px]:block hidden h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))] @min-[961px]:layout:[--fd-sidebar-width:300px] [grid-area:sidebar] *:pointer-events-auto", "data-sidebar-placeholder": true, children: _jsx("aside", { className: "h-full w-[300px] pr-3 text-gray-900", children: _jsxs("nav", { "aria-label": "Documentation", className: "geistdocs-sidebar-scroll h-full w-full overflow-auto overflow-x-hidden px-1 pt-14 pb-1 outline-none", "data-geistdocs-sidebar-scroll": true, ref: navRef, children: [top ? _jsx("div", { className: "px-2 pb-3", children: top }) : null, _jsxs("div", { className: "relative overflow-hidden", children: [_jsx("div", { className: cn("geistdocs-sidebar-pane", rootHidden &&
291
+ "pointer-events-none absolute inset-x-0 top-0 opacity-0 [transform:translateX(-8px)] motion-reduce:invisible"), "data-sidebar-pane": "root", inert: rootHidden || undefined, children: _jsx(SidebarRootList, { activeSection: activeSection, activeUrl: activeUrl, groups: groups, onSelect: (section, trigger) => {
292
+ returnFocusRef.current = trigger;
293
+ shouldFocusSectionRef.current = true;
294
+ setSelectedSection(section);
295
+ setView("section");
296
+ }, visible: !rootHidden }) }), activeSection ? (_jsxs("div", { className: cn("geistdocs-sidebar-pane", sectionHidden &&
297
+ "pointer-events-none absolute inset-x-0 top-0 opacity-0 [transform:translateX(8px)] motion-reduce:invisible"), "data-sidebar-pane": "section", inert: sectionHidden || undefined, children: [_jsx(SidebarSectionHeader, { buttonRef: sectionHeaderRef, onBack: () => {
298
+ shouldFocusRootRef.current = true;
299
+ setSelectedSection(null);
300
+ setView("root");
301
+ }, section: activeSection }), _jsx("div", { className: "px-2", children: _jsx(SidebarTree, { activeUrl: activeUrl, idScope: sectionScope, nodes: sectionItems, openFirstLevel: true, scrollActive: true, visible: !sectionHidden }) })] })) : null] })] }) }) }));
302
+ };
303
+ const MobileSidebar = ({ activeUrl, idScope, nodes, onOpenChange, open, top, }) => (_jsx(Sheet, { onOpenChange: onOpenChange, open: open, children: _jsxs(SheetContent, { className: "gap-0 p-0", "data-geistdocs-mobile-sidebar": true, side: "left", children: [_jsxs(SheetHeader, { className: "h-16 shrink-0 justify-center border-b px-4 py-0", children: [_jsx(SheetTitle, { className: "text-label-16", children: "Browse" }), _jsx(SheetDescription, { className: "sr-only", children: "Navigation for the documentation." })] }), _jsxs("nav", { "aria-label": "Documentation", className: "flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-2 py-3 text-gray-900", "data-geistdocs-sidebar-scroll": true, children: [_jsx("div", { className: "pb-4 [&>button]:w-full", children: _jsx(SearchButton, { onClick: () => onOpenChange(false) }) }), top ? _jsx("div", { className: "pb-4", children: top }) : null, _jsx(SidebarTree, { activeUrl: activeUrl, idScope: idScope, nodes: nodes, onNavigate: () => onOpenChange(false), scrollActive: true, visible: open })] })] }) }));
304
+ export const GeistdocsSidebar = ({ showDesktop = true, top, }) => {
51
305
  const { root, full } = useTreeContext();
52
306
  const { isOpen, setIsOpen } = useGeistdocsSidebar();
307
+ const containerMarkerRef = useRef(null);
53
308
  const pathname = usePathname();
54
309
  const previousPathname = useRef(pathname);
55
310
  const params = useParams();
56
311
  const slugKey = Array.isArray(params.slug)
57
312
  ? params.slug.join("/")
58
313
  : (params.slug ?? "");
59
- const activePath = useMemo(() => {
60
- const activeUrl = findActiveUrl(full.children, slugKey);
61
- return activeUrl ? (searchPath(full.children, activeUrl) ?? []) : [];
62
- }, [full, slugKey]);
314
+ const activeUrl = useMemo(() => findActiveUrl(full.children, slugKey) ??
315
+ findActiveUrlFromPathname(root.children, pathname), [full, pathname, root, slugKey]);
316
+ const rootScope = useMemo(() => root.$id ?? findShortestPageUrl(root.children) ?? "root", [root]);
63
317
  useEffect(() => {
64
318
  if (pathname !== previousPathname.current) {
65
319
  setIsOpen(false);
66
320
  previousPathname.current = pathname;
67
321
  }
68
322
  }, [pathname, setIsOpen]);
69
- const renderSidebarList = (items) => items.map((item) => {
70
- if (item.type === "separator") {
71
- return _jsx(GeistdocsSidebarSeparator, { item: item }, item.$id);
72
- }
73
- if (item.type === "folder") {
74
- return (_jsx(GeistdocsSidebarFolder, { item: item, children: renderSidebarList(item.children) }, item.$id));
323
+ useEffect(() => {
324
+ const container = containerMarkerRef.current?.closest("[data-geistdocs-container]");
325
+ if (!container) {
326
+ return;
75
327
  }
76
- return _jsx(GeistdocsSidebarItem, { item: item }, item.$id);
77
- });
78
- return (_jsx(SidebarActivePathContext.Provider, { value: activePath, children: _jsxs("div", { className: "pointer-events-none sticky top-(--fd-docs-row-1) z-20 h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))] [grid-area:sidebar] *:pointer-events-auto max-md:hidden md:layout:[--fd-sidebar-width:268px]", "data-sidebar-placeholder": true, children: [_jsxs("div", { className: "h-full overflow-y-auto px-4 pt-12 pb-4", children: [top ? _jsx("div", { className: "mb-4", children: top }) : null, _jsx(Fragment, { children: renderSidebarList(root.children) }, root.$id)] }), _jsx(Sheet, { onOpenChange: setIsOpen, open: isOpen, children: _jsxs(SheetContent, { className: "gap-0", side: "left", children: [_jsxs(SheetHeader, { className: "mt-8", children: [_jsx(SheetTitle, { className: "sr-only", children: "Mobile Menu" }), _jsx(SheetDescription, { className: "sr-only", children: "Navigation for the documentation." }), _jsx(SearchButton, { onClick: () => setIsOpen(false) })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-4 pb-4", children: [top ? _jsx("div", { className: "mb-4", children: top }) : null, renderSidebarList(root.children)] })] }) })] }) }));
79
- };
80
- export const GeistdocsSidebarFolder = ({ children, item, }) => {
81
- const activePath = useContext(SidebarActivePathContext);
82
- const defaultOpen = item.defaultOpen ?? activePath.includes(item);
83
- return (_jsxs(SidebarFolder, { defaultOpen: defaultOpen, children: [item.index ? (_jsxs(SidebarFolderLink, { className: "flex items-center gap-2 text-pretty py-1.5 text-gray-800 text-sm transition-colors hover:text-gray-1000 data-[active=true]:text-gray-1000 [&_svg]:size-3.5", external: item.index.external, href: item.index.url, children: [item.icon, item.name] })) : (_jsxs(SidebarFolderTrigger, { className: "flex items-center gap-2 text-pretty py-1.5 text-gray-800 text-sm transition-colors hover:text-gray-1000 [&_svg]:size-3.5", children: [item.icon, item.name] })), _jsx(SidebarFolderContent, { className: "ml-2", children: children })] }));
84
- };
85
- export const GeistdocsSidebarItem = ({ item, }) => {
86
- const activePath = useContext(SidebarActivePathContext);
87
- // fumadocs' SidebarItem marks active from usePathname() (empty at prerender),
88
- // so derive it from the params path (active page is its last node) to keep the
89
- // marker in the static HTML. Overrides fumadocs' value, which is spread last.
90
- const active = activePath.at(-1) === item;
91
- return (_jsx(SidebarItem, { className: "block w-full truncate text-pretty py-1.5 text-gray-800 text-sm transition-colors hover:text-gray-1000 data-[active=true]:text-gray-1000", "data-active": active, external: item.external, href: item.url, icon: item.icon, children: item.name }));
328
+ return observeSidebarContainer(container, () => setIsOpen(false));
329
+ }, [setIsOpen]);
330
+ return (_jsxs(_Fragment, { children: [_jsx("span", { hidden: true, ref: containerMarkerRef }), showDesktop ? (_jsx(DesktopSidebar, { activeUrl: activeUrl, nodes: root.children, rootScope: rootScope, top: top }, root.$id)) : null, _jsx(MobileSidebar, { activeUrl: activeUrl, idScope: rootScope, nodes: root.children, onOpenChange: setIsOpen, open: isOpen, top: top })] }));
92
331
  };
93
- export const GeistdocsSidebarSeparator = ({ item }) => (_jsxs(SidebarSeparator, { className: "mt-4 mb-2 flex items-center gap-2 px-0 font-medium text-sm first-child:mt-0", children: [item.icon, item.name] }));
@@ -2,4 +2,4 @@
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { TOCItems } from "fumadocs-ui/components/toc/clerk";
4
4
  import { TOCScrollArea } from "fumadocs-ui/components/toc/index";
5
- export const GeistdocsTableOfContents = ({ footer, header, toc, }) => (_jsx("aside", { "aria-label": "Page navigation", className: "sticky top-(--fd-docs-row-1) hidden h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))] w-(--fd-toc-width) flex-col pt-12 pr-4 pb-2 [grid-area:toc] xl:flex", id: "nd-toc", children: _jsxs("nav", { "aria-label": "On this page", className: "flex min-h-0 flex-1 flex-col", children: [header, toc.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "mb-2 font-medium text-gray-1000 text-sm", children: "On this page" }), _jsx(TOCScrollArea, { children: _jsx(TOCItems, {}) })] })) : null, footer] }) }));
5
+ export const GeistdocsTableOfContents = ({ footer, header, toc, }) => (_jsx("aside", { "aria-label": "Page navigation", className: "sticky top-(--fd-docs-row-1) hidden h-[calc(var(--fd-docs-height)-var(--fd-docs-row-1))] w-(--fd-toc-width) flex-col pt-14 pr-4 pb-2 [grid-area:toc] xl:flex", id: "nd-toc", children: _jsxs("nav", { "aria-label": "On this page", className: "flex min-h-0 flex-1 flex-col", children: [header, toc.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "mb-2 font-medium text-gray-1000 text-sm", children: "On this page" }), _jsx(TOCScrollArea, { children: _jsx(TOCItems, {}) })] })) : null, footer] }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../../src/internal/ui/sheet.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5C,wBAAgB,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,2CAEtE;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,IAAc,EACd,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG;IACjD,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC5C,2CA+BA;AAED,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,2CAQzE;AAED,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,cAAc,CAAC,KAAK,CAAC,2CAQ7C;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,cAAc,CAAC,WAAW,CAAC,2CAQnD"}
1
+ {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../../src/internal/ui/sheet.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5C,wBAAgB,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,2CAEtE;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,IAAc,EACd,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG;IACjD,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC5C,2CAkCA;AAED,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,2CAQzE;AAED,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,cAAc,CAAC,KAAK,CAAC,2CAQ7C;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,cAAc,CAAC,WAAW,CAAC,2CAQnD"}
@@ -7,11 +7,11 @@ export function Sheet(props) {
7
7
  return _jsx(SheetPrimitive.Root, { "data-slot": "sheet", ...props });
8
8
  }
9
9
  export function SheetContent({ className, children, side = "right", ...props }) {
10
- return (_jsxs(SheetPrimitive.Portal, { "data-slot": "sheet-portal", children: [_jsx(SheetPrimitive.Overlay, { className: "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in", "data-slot": "sheet-overlay" }), _jsxs(SheetPrimitive.Content, { className: cn("fixed z-50 flex flex-col gap-4 bg-background-100 shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:duration-300 data-[state=open]:duration-500", side === "right" &&
10
+ return (_jsxs(SheetPrimitive.Portal, { "data-slot": "sheet-portal", children: [_jsx(SheetPrimitive.Overlay, { className: "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-gray-alpha-800 duration-300 ease-[cubic-bezier(0.175,0.885,0.32,1.1)] data-[state=closed]:animate-out data-[state=open]:animate-in motion-reduce:animate-none", "data-slot": "sheet-overlay" }), _jsxs(SheetPrimitive.Content, { className: cn("fixed z-50 flex flex-col gap-4 bg-background-100 shadow-[var(--ds-shadow-modal)] duration-300 ease-[cubic-bezier(0.175,0.885,0.32,1.1)] data-[state=closed]:animate-out data-[state=open]:animate-in motion-reduce:animate-none", side === "right" &&
11
11
  "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm", side === "left" &&
12
12
  "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm", side === "top" &&
13
13
  "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b", side === "bottom" &&
14
- "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t", className), "data-slot": "sheet-content", ...props, children: [children, _jsxs(SheetPrimitive.Close, { className: "absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background-100 transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-gray-600 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100", children: [_jsx(XIcon, { className: "size-4" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })] }));
14
+ "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t", className), "data-slot": "sheet-content", ...props, children: [children, _jsxs(SheetPrimitive.Close, { className: "absolute top-4 right-4 grid size-8 touch-manipulation place-items-center rounded-md text-gray-900 transition-colors hover:bg-gray-alpha-100 hover:text-gray-1000 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none disabled:pointer-events-none data-[state=open]:bg-gray-alpha-100 motion-reduce:transition-none", "data-slot": "sheet-close", children: [_jsx(XIcon, { className: "size-4" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })] }));
15
15
  }
16
16
  export function SheetHeader({ className, ...props }) {
17
17
  return (_jsx("div", { className: cn("flex flex-col gap-1.5 p-4", className), "data-slot": "sheet-header", ...props }));
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAWhD,eAAO,MAAM,iBAAiB,iHAA0B,CAAC;AAEzD,UAAU,wBAAwB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,cAAc,CAAC,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC7E,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,IAAI,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,mBAAmB,GAAI,yDAMjC,wBAAwB,4CAuC1B,CAAC"}
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAMhD,eAAO,MAAM,iBAAiB,iHAA0B,CAAC;AAEzD,UAAU,wBAAwB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAClE,cAAc,CAAC,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC7E,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,IAAI,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;CACzD;AAED,eAAO,MAAM,mBAAmB,GAAI,yDAMjC,wBAAwB,4CAkC1B,CAAC"}
package/dist/layout.js CHANGED
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { DocsLayout as FumadocsDocsLayout } from "fumadocs-ui/layouts/docs";
3
3
  import { createGeistdocsI18n } from "./internal/i18n";
4
4
  import { GeistdocsProvider as GeistdocsProviderClient } from "./internal/provider-client";
5
- import { GeistdocsSidebar, GeistdocsSidebarFolder, GeistdocsSidebarItem, GeistdocsSidebarSeparator, } from "./internal/sidebar";
5
+ import { GeistdocsSidebar } from "./internal/sidebar";
6
6
  import { GeistdocsSidebarProvider } from "./sidebar";
7
7
  export const GeistdocsProvider = GeistdocsProviderClient;
8
8
  export const GeistdocsDocsLayout = ({ config, containerProps, sidebarTop, tree, children, }) => {
@@ -20,11 +20,6 @@ export const GeistdocsDocsLayout = ({ config, containerProps, sidebarTop, tree,
20
20
  }, sidebar: {
21
21
  collapsible: false,
22
22
  component: _jsx(GeistdocsSidebar, { top: sidebarTop }),
23
- components: {
24
- Folder: GeistdocsSidebarFolder,
25
- Item: GeistdocsSidebarItem,
26
- Separator: GeistdocsSidebarSeparator,
27
- },
28
23
  }, tabMode: "auto", themeSwitch: {
29
24
  enabled: false,
30
25
  }, tree: tree, children: children }) }));
package/dist/mdx.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare const geistdocsFrontmatterSchema: import("zod").ZodObject<{
7
7
  icon: import("zod").ZodOptional<import("zod").ZodString>;
8
8
  full: import("zod").ZodOptional<import("zod").ZodBoolean>;
9
9
  _openapi: import("zod").ZodOptional<import("zod").ZodObject<{}, import("zod/v4/core").$loose>>;
10
+ badge: import("zod").ZodOptional<import("zod").ZodString>;
10
11
  product: import("zod").ZodOptional<import("zod").ZodString>;
11
12
  url: import("zod").ZodOptional<import("zod").ZodString>;
12
13
  type: import("zod").ZodOptional<import("zod").ZodEnum<{
package/dist/mdx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../src/mdx.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAkB/C,OAAO,EAGL,KAAK,4BAA4B,IAAI,mBAAmB,EAGzD,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,2BAA2B,8EAAe,CAAC;AACxD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAoB,CAAC;AAC5D,eAAO,MAAM,mBAAmB;;;;;;;gCAAa,CAAC;AAC9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAAa,CAAC;AAC1C,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAEnD,eAAO,MAAM,yBAAyB,GACpC,aAAa,sBAAsB,KAClC,sBA8BD,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,sBAAsB,KAClC,sBAA+D,CAAC;AAEnE,eAAO,MAAM,2BAA2B,GACtC,GAAG,eAAe,KAAK,CAAC,sBAAsB,GAAG,SAAS,CAAC,KAC1D,sBACkD,CAAC"}
1
+ {"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../src/mdx.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAkB/C,OAAO,EAGL,KAAK,4BAA4B,IAAI,mBAAmB,EAGzD,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,2BAA2B,8EAAe,CAAC;AACxD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAoB,CAAC;AAC5D,eAAO,MAAM,mBAAmB;;;;;;;gCAAa,CAAC;AAC9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAAa,CAAC;AAC1C,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAEnD,eAAO,MAAM,yBAAyB,GACpC,aAAa,sBAAsB,KAClC,sBA8BD,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,sBAAsB,KAClC,sBAA+D,CAAC;AAEnE,eAAO,MAAM,2BAA2B,GACtC,GAAG,eAAe,KAAK,CAAC,sBAAsB,GAAG,SAAS,CAAC,KAC1D,sBACkD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mobile-docs-bar.d.ts","sourceRoot":"","sources":["../src/mobile-docs-bar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAazD,UAAU,kBAAkB;IAC1B,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,GAAI,SAAS,kBAAkB,4CAyDxD,CAAC"}
1
+ {"version":3,"file":"mobile-docs-bar.d.ts","sourceRoot":"","sources":["../src/mobile-docs-bar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAczD,UAAU,kBAAkB;IAC1B,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,GAAI,SAAS,kBAAkB,4CAuExD,CAAC"}
@@ -4,10 +4,10 @@ import { useState } from "react";
4
4
  import { IconFileText } from "./assets/icons/icon-file-text";
5
5
  import { IconMenuAlt } from "./assets/icons/icon-menu-alt";
6
6
  import { cn } from "./internal/cn";
7
- import { Sheet, SheetContent, SheetDescription, SheetHeader, } from "./internal/ui/sheet";
7
+ import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "./internal/ui/sheet";
8
8
  import { useGeistdocsSidebar } from "./sidebar";
9
9
  export const MobileDocsBar = ({ toc }) => {
10
- const { setIsOpen: setSidebarOpen } = useGeistdocsSidebar();
10
+ const { isOpen: sidebarOpen, setIsOpen: setSidebarOpen } = useGeistdocsSidebar();
11
11
  const [tocOpen, setTocOpen] = useState(false);
12
- return (_jsxs("div", { className: "sticky top-16 z-30 -mx-6 -mt-6 mb-6 flex h-[54px] items-center justify-between border-b bg-background-100 px-6 md:hidden", children: [_jsxs("button", { className: "flex items-center gap-3 text-base text-gray-1000", onClick: () => setSidebarOpen(true), type: "button", children: [_jsx(IconMenuAlt, { size: 16 }), "Menu"] }), toc && toc.length > 0 && (_jsxs(_Fragment, { children: [_jsx("button", { "aria-label": "Table of contents", className: "flex size-8 items-center justify-center rounded-md border border-gray-200 text-gray-900 transition-colors hover:bg-gray-100 hover:text-gray-1000", onClick: () => setTocOpen(true), type: "button", children: _jsx(IconFileText, { size: 16 }) }), _jsx(Sheet, { onOpenChange: setTocOpen, open: tocOpen, children: _jsxs(SheetContent, { className: "w-72 gap-0", side: "right", children: [_jsx(SheetHeader, { children: _jsx(SheetDescription, { className: "sr-only", children: "Table of contents for the current page." }) }), _jsx("nav", { className: "flex-1 overflow-y-auto px-4 pb-4", children: _jsx("ul", { className: "space-y-1", children: toc.map((item) => (_jsx("li", { children: _jsx("a", { className: cn("block rounded-md py-1.5 text-gray-900 text-sm transition-colors hover:text-gray-1000", item.depth > 2 && "pl-4"), href: item.url, onClick: () => setTocOpen(false), children: item.title }) }, item.url))) }) })] }) })] }))] }));
12
+ return (_jsxs("div", { className: "sticky top-16 z-30 -mx-6 -mt-6 mb-6 flex @min-[961px]:hidden h-[54px] items-center justify-between border-b bg-background-100 px-6", "data-mobile-docs-bar": true, children: [_jsxs("button", { "aria-expanded": sidebarOpen, "aria-haspopup": "dialog", className: "-ml-2 flex min-h-8 touch-manipulation items-center gap-3 rounded-md px-2 text-gray-1000 text-label-16 transition-colors hover:bg-gray-alpha-100 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:bg-gray-alpha-300 motion-reduce:transition-none", onClick: () => setSidebarOpen(true), type: "button", children: [_jsx(IconMenuAlt, { size: 16 }), "Menu"] }), toc && toc.length > 0 && (_jsxs(_Fragment, { children: [_jsx("button", { "aria-expanded": tocOpen, "aria-haspopup": "dialog", "aria-label": "Table of contents", className: "flex size-8 touch-manipulation items-center justify-center rounded-md border border-gray-alpha-400 text-gray-900 transition-colors hover:border-gray-alpha-500 hover:bg-gray-alpha-100 hover:text-gray-1000 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:border-gray-alpha-600 active:bg-gray-alpha-300 motion-reduce:transition-none", "data-mobile-toc-trigger": true, onClick: () => setTocOpen(true), type: "button", children: _jsx(IconFileText, { size: 16 }) }), _jsx(Sheet, { onOpenChange: setTocOpen, open: tocOpen, children: _jsxs(SheetContent, { className: "w-72 gap-0", "data-geistdocs-mobile-toc": true, side: "right", children: [_jsxs(SheetHeader, { children: [_jsx(SheetTitle, { className: "sr-only", children: "On This Page" }), _jsx(SheetDescription, { className: "sr-only", children: "Table of contents for the current page." })] }), _jsx("nav", { className: "flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-4 pb-4", children: _jsx("ul", { className: "space-y-1", children: toc.map((item) => (_jsx("li", { children: _jsx("a", { className: cn("block break-words rounded-md py-1.5 text-gray-900 text-sm transition-colors hover:text-gray-1000 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none motion-reduce:transition-none", item.depth > 2 && "pl-4"), href: item.url, onClick: () => setTocOpen(false), children: item.title }) }, item.url))) }) })] }) })] }))] }));
13
13
  };
package/dist/navbar.js CHANGED
@@ -4,7 +4,7 @@ import { GitHubButton, getGithubRepoUrl } from "./internal/github-button";
4
4
  import { DesktopMenu } from "./internal/navbar/desktop-menu";
5
5
  import { MobileMenu } from "./internal/navbar/mobile-menu";
6
6
  import { NavbarLogo } from "./internal/navbar/navbar-logo";
7
- const SEARCH_BUTTON_CLASSES = "group hidden h-10 justify-between gap-8 pr-1.5 font-normal text-gray-800 shadow-none @min-[1024px]:flex @min-[1024px]:h-8 @min-[1024px]:w-[150px] @min-[1024px]:bg-background-200 hover:@min-[1024px]:bg-background-200 [&_[data-slot=kbd]]:transition-colors group-hover:[&_[data-slot=kbd]]:text-gray-1000";
7
+ const SEARCH_BUTTON_CLASSES = "group hidden h-10 justify-between pr-1.5 text-gray-900 shadow-none @min-[1024px]:flex @min-[1024px]:h-8 @min-[1024px]:w-[150px] [&_[data-slot=kbd]]:transition-colors group-hover:[&_[data-slot=kbd]]:text-gray-1000";
8
8
  export const Navbar = ({ config }) => {
9
9
  const nav = config.nav ?? [];
10
10
  const variant = config.navbarVariant ?? "oss";
@@ -78,7 +78,7 @@ export const createDocsPage = ({ config, source, mdx, pageActions = createIntern
78
78
  single: true,
79
79
  ...tableOfContent,
80
80
  component: tocComponent,
81
- }, tableOfContentPopover: tableOfContentPopover, toc: data.toc, children: [renderTop?.({ data, markdown: markdown ?? "", page, pageUrl }), _jsxs("div", { className: "flex flex-col-reverse gap-4 sm:flex-row sm:items-start sm:justify-between", children: [_jsx(DocsTitle, { className: "mb-0 min-w-0", children: data.title }), _jsx(GeistdocsPageActions, { config: pageActions.config, page: {
81
+ }, tableOfContentPopover: tableOfContentPopover, toc: data.toc, children: [renderTop?.({ data, markdown: markdown ?? "", page, pageUrl }), _jsxs("div", { className: "flex flex-col-reverse gap-4 sm:flex-row sm:items-end sm:justify-between", children: [_jsx(DocsTitle, { className: "mb-0 min-w-0", children: data.title }), _jsx(GeistdocsPageActions, { config: pageActions.config, page: {
82
82
  path: page.path,
83
83
  url: pageUrl,
84
84
  } })] }), _jsx(DocsDescription, { children: data.description }), _jsx(DocsBody, { children: _jsx(MDX, { components: {
@@ -30,6 +30,7 @@ export declare const geistdocsFrontmatterSchema: z.ZodObject<{
30
30
  icon: z.ZodOptional<z.ZodString>;
31
31
  full: z.ZodOptional<z.ZodBoolean>;
32
32
  _openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
33
+ badge: z.ZodOptional<z.ZodString>;
33
34
  product: z.ZodOptional<z.ZodString>;
34
35
  url: z.ZodOptional<z.ZodString>;
35
36
  type: z.ZodOptional<z.ZodEnum<{
@@ -1 +1 @@
1
- {"version":3,"file":"source-config.d.ts","sourceRoot":"","sources":["../src/source-config.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,IAAI,oBAAoB,EAGrC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAsG3B,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCrC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;iBAAa,CAAC;AAE9C,eAAO,MAAM,2BAA2B,GACtC,SAAQ,4BAAiC,+CAoB1C,CAAC"}
1
+ {"version":3,"file":"source-config.d.ts","sourceRoot":"","sources":["../src/source-config.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,IAAI,oBAAoB,EAGrC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAsG3B,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCrC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;iBAAa,CAAC;AAE9C,eAAO,MAAM,2BAA2B,GACtC,SAAQ,4BAAiC,+CAoB1C,CAAC"}
@@ -106,6 +106,7 @@ export const geistShikiTheme = {
106
106
  ],
107
107
  };
108
108
  export const geistdocsFrontmatterSchema = frontmatterSchema.extend({
109
+ badge: z.string().optional(),
109
110
  product: z.string().optional(),
110
111
  url: z
111
112
  .string()
package/dist/source.d.ts CHANGED
@@ -5,6 +5,7 @@ export interface FumadocsCollection {
5
5
  toFumadocsSource(): LoaderOptions["source"];
6
6
  }
7
7
  export interface GeistdocsSourcePageData {
8
+ badge?: string;
8
9
  canonical?: string;
9
10
  description?: string;
10
11
  excludeFrom?: GeistdocsPageSurface[];
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEtE,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAElD,MAAM,WAAW,kBAAkB;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BQ,aAAa;;;OAAe;;;;4BAWnB,aAAa;;;OAAe;CAiFlE,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAEpE,eAAO,MAAM,uBAAuB,GAClC,QAAQ,OAAO,KACd,MAAM,IAAI,qBAKC,CAAC;AAEf,eAAO,MAAM,aAAa,GAAI,qBAAqB,oBAAoB;;;;;;;;;;;;iCAzGzC,aAAa;;;eAAe;;;;oCAWnB,aAAa;;;eAAe;;;UAkH1D,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC;CAE7C,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,gCAIpC,6BAA6B;;;;;;;;;;;;;;;iCArIF,aAAa;;;eAAe;;;;oCAWnB,aAAa;;;eAAe;;;;;;;;;;;6BAXrC,aAAa;;;WAAe;;;;gCAWnB,aAAa;;;WAAe;;;;;;;;;;6BAXrC,aAAa;;;WAAe;;;;gCAWnB,aAAa;;;WAAe;;;CA6JlE,CAAC"}
package/dist/source.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineI18n } from "fumadocs-core/i18n";
2
- import { loader } from "fumadocs-core/source";
2
+ import { loader, } from "fumadocs-core/source";
3
3
  import { lucideIconsPlugin } from "fumadocs-core/source/lucide-icons";
4
4
  const getLanguages = (config) => {
5
5
  const defaultLanguage = config.defaultLanguage ?? "en";
@@ -9,6 +9,21 @@ const getLanguages = (config) => {
9
9
  languages: Array.from(new Set([defaultLanguage, ...languages])),
10
10
  };
11
11
  };
12
+ const badgePageTreeTransformer = {
13
+ file(node, filePath) {
14
+ if (!filePath) {
15
+ return node;
16
+ }
17
+ const file = this.storage.read(filePath);
18
+ if (file?.format !== "page") {
19
+ return node;
20
+ }
21
+ const badge = file.data.badge;
22
+ return typeof badge === "string" && badge.length > 0
23
+ ? { ...node, badge }
24
+ : node;
25
+ },
26
+ };
12
27
  export const createSource = ({ docs, config, baseUrl = "/docs", id, label, markdown, }) => {
13
28
  const { defaultLanguage, languages } = getLanguages(config);
14
29
  const i18n = defineI18n({
@@ -19,6 +34,9 @@ export const createSource = ({ docs, config, baseUrl = "/docs", id, label, markd
19
34
  const source = loader({
20
35
  i18n,
21
36
  baseUrl,
37
+ pageTree: {
38
+ transformers: [badgePageTreeTransformer],
39
+ },
22
40
  source: docs.toFumadocsSource(),
23
41
  plugins: [lucideIconsPlugin()],
24
42
  });
@@ -34,11 +52,12 @@ export const createSource = ({ docs, config, baseUrl = "/docs", id, label, markd
34
52
  const getPageMarkdown = async (page) => {
35
53
  const data = page.data;
36
54
  const processed = await data.getText("processed");
37
- const { title, description, product, type, summary, prerequisites, related, internal, noindex, canonical, tags, keywords, excludeFrom, } = data;
55
+ const { title, description, badge, product, type, summary, prerequisites, related, internal, noindex, canonical, tags, keywords, excludeFrom, } = data;
38
56
  const frontmatter = [
39
57
  "---",
40
58
  `title: ${title}`,
41
59
  description && `description: ${description}`,
60
+ badge && `badge: ${JSON.stringify(badge)}`,
42
61
  product && `product: ${product}`,
43
62
  type && `type: ${type}`,
44
63
  summary && `summary: ${summary}`,