@farming-labs/theme 0.2.138 → 0.2.139-beta.1

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.
@@ -7,7 +7,8 @@ const PROMPT_PROVIDER_TEMPLATES = {
7
7
  cursor: "https://cursor.com/link/prompt?text={prompt}",
8
8
  gemini: "https://gemini.google.com/app?q={prompt}",
9
9
  copilot: "https://github.com/copilot?prompt={prompt}",
10
- perplexity: "https://www.perplexity.ai/search/?q={prompt}"
10
+ perplexity: "https://www.perplexity.ai/search/?q={prompt}",
11
+ codex: "codex://new?prompt={prompt}"
11
12
  };
12
13
  const OPEN_DOCS_PROVIDER_PRESETS = {
13
14
  chatgpt: {
@@ -46,6 +47,12 @@ const OPEN_DOCS_PROVIDER_PRESETS = {
46
47
  urlTemplate: "https://www.perplexity.ai/search/?q={prompt}",
47
48
  promptUrlTemplate: PROMPT_PROVIDER_TEMPLATES.perplexity
48
49
  },
50
+ codex: {
51
+ name: "Codex",
52
+ iconHtml: OPEN_DOCS_PROVIDER_ICONS.chatgpt,
53
+ urlTemplate: "codex://new?prompt={prompt}",
54
+ promptUrlTemplate: PROMPT_PROVIDER_TEMPLATES.codex
55
+ },
49
56
  github: {
50
57
  name: "GitHub",
51
58
  iconHtml: OPEN_DOCS_PROVIDER_ICONS.github,
@@ -0,0 +1,10 @@
1
+ import "@farming-labs/docs";
2
+
3
+ //#region src/page-actions-config.d.ts
4
+ interface ResolvedTocPageActions {
5
+ copyMarkdown: boolean;
6
+ viewMarkdown: boolean;
7
+ editOnGitHub: boolean;
8
+ }
9
+ //#endregion
10
+ export { ResolvedTocPageActions };
@@ -0,0 +1,14 @@
1
+ //#region src/page-actions-config.ts
2
+ /** Resolve `pageActions.toc` to the actions shown in the table-of-contents rail. */
3
+ function resolveTocPageActions(toc) {
4
+ if (!toc) return void 0;
5
+ const picked = toc === true ? {} : toc;
6
+ return {
7
+ copyMarkdown: picked.copyMarkdown !== false,
8
+ viewMarkdown: picked.viewMarkdown !== false,
9
+ editOnGitHub: picked.editOnGitHub !== false
10
+ };
11
+ }
12
+
13
+ //#endregion
14
+ export { resolveTocPageActions };
@@ -0,0 +1,130 @@
1
+ "use client";
2
+
3
+ import { useRef, useState } from "react";
4
+ import { Popover, PopoverContent, PopoverTrigger } from "fumadocs-ui/components/ui/popover";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
+
7
+ //#region src/page-actions-menu.tsx
8
+ const MoreIcon = () => /* @__PURE__ */ jsxs("svg", {
9
+ width: "16",
10
+ height: "16",
11
+ viewBox: "0 0 24 24",
12
+ fill: "none",
13
+ stroke: "currentColor",
14
+ strokeWidth: "2",
15
+ strokeLinecap: "round",
16
+ strokeLinejoin: "round",
17
+ "aria-hidden": "true",
18
+ children: [
19
+ /* @__PURE__ */ jsx("circle", {
20
+ cx: "12",
21
+ cy: "12",
22
+ r: "1"
23
+ }),
24
+ /* @__PURE__ */ jsx("circle", {
25
+ cx: "19",
26
+ cy: "12",
27
+ r: "1"
28
+ }),
29
+ /* @__PURE__ */ jsx("circle", {
30
+ cx: "5",
31
+ cy: "12",
32
+ r: "1"
33
+ })
34
+ ]
35
+ });
36
+ /**
37
+ * A "…" trigger opening a menu of page actions. It follows the WAI-ARIA menu button pattern:
38
+ * arrow keys, Home and End move between items, Escape closes and returns focus to the trigger.
39
+ */
40
+ function PageActionsMenu({ items, label = "More page actions" }) {
41
+ const [open, setOpen] = useState(false);
42
+ const contentRef = useRef(null);
43
+ const initialFocus = useRef("first");
44
+ if (items.length === 0) return null;
45
+ const menuItems = () => Array.from(contentRef.current?.querySelectorAll("[role=\"menuitem\"]") ?? []);
46
+ const focusItem = (index) => {
47
+ const list = menuItems();
48
+ list[(index + list.length) % list.length]?.focus();
49
+ };
50
+ const onTriggerKeyDown = (event) => {
51
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
52
+ event.preventDefault();
53
+ initialFocus.current = event.key === "ArrowUp" ? "last" : "first";
54
+ setOpen(true);
55
+ };
56
+ const onMenuKeyDown = (event) => {
57
+ const current = menuItems().indexOf(document.activeElement);
58
+ if (event.key === "ArrowDown") focusItem(current + 1);
59
+ else if (event.key === "ArrowUp") focusItem(current < 0 ? -1 : current - 1);
60
+ else if (event.key === "Home") focusItem(0);
61
+ else if (event.key === "End") focusItem(-1);
62
+ else {
63
+ if (event.key === "Tab") setOpen(false);
64
+ return;
65
+ }
66
+ event.preventDefault();
67
+ };
68
+ return /* @__PURE__ */ jsxs(Popover, {
69
+ open,
70
+ onOpenChange: (next) => {
71
+ if (next) initialFocus.current = "first";
72
+ setOpen(next);
73
+ },
74
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
75
+ className: "fd-page-action-btn fd-page-actions-menu-trigger",
76
+ "aria-label": label,
77
+ "aria-haspopup": "menu",
78
+ title: label,
79
+ onKeyDown: onTriggerKeyDown,
80
+ children: /* @__PURE__ */ jsx(MoreIcon, {})
81
+ }), /* @__PURE__ */ jsx(PopoverContent, {
82
+ ref: contentRef,
83
+ role: "menu",
84
+ "aria-label": label,
85
+ align: "end",
86
+ className: "fd-page-actions-menu",
87
+ onOpenAutoFocus: (event) => {
88
+ event.preventDefault();
89
+ focusItem(initialFocus.current === "last" ? -1 : 0);
90
+ },
91
+ onKeyDown: onMenuKeyDown,
92
+ children: items.map((item) => {
93
+ const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [item.icon && /* @__PURE__ */ jsx("span", {
94
+ className: "fd-page-action-menu-icon",
95
+ "aria-hidden": "true",
96
+ children: item.icon
97
+ }), /* @__PURE__ */ jsx("span", {
98
+ className: "fd-page-action-menu-label",
99
+ children: item.label
100
+ })] });
101
+ return item.href ? /* @__PURE__ */ jsx("a", {
102
+ role: "menuitem",
103
+ tabIndex: -1,
104
+ className: "fd-page-action-menu-item",
105
+ href: item.href,
106
+ target: "_blank",
107
+ rel: "noreferrer noopener",
108
+ onClick: () => {
109
+ item.onSelect?.();
110
+ setOpen(false);
111
+ },
112
+ children: content
113
+ }, item.key) : /* @__PURE__ */ jsx("button", {
114
+ type: "button",
115
+ role: "menuitem",
116
+ tabIndex: -1,
117
+ className: "fd-page-action-menu-item",
118
+ onClick: () => {
119
+ item.onSelect?.();
120
+ setOpen(false);
121
+ },
122
+ children: content
123
+ }, item.key);
124
+ })
125
+ })]
126
+ });
127
+ }
128
+
129
+ //#endregion
130
+ export { PageActionsMenu };
@@ -17,14 +17,19 @@ interface PageActionsProps {
17
17
  copyMarkdownLabel?: string;
18
18
  copyMarkdownCopiedLabel?: string;
19
19
  openDocs?: boolean;
20
+ /** Link to the page's Markdown route. */
21
+ viewMarkdown?: boolean;
20
22
  providers?: SerializedProvider[];
21
23
  openDocsTarget?: "markdown" | "page" | "source" | "github";
22
24
  openDocsPrompt?: string;
23
25
  alignment?: "left" | "right";
24
- variant?: "default" | "rail";
26
+ /** `menu` collects every enabled action behind one "…" trigger. */
27
+ variant?: "default" | "rail" | "menu";
25
28
  /** GitHub file URL (edit view) for the current page. Used when urlTemplate contains {githubUrl}. */
26
29
  githubFileUrl?: string | null;
27
30
  analytics?: boolean;
31
+ /** The rail's "Ask AI" button. */
32
+ askAi?: boolean;
28
33
  connectMcp?: {
29
34
  endpoint?: string;
30
35
  providers?: readonly PageActionMcpProvider[];
@@ -50,6 +55,7 @@ declare function PageActions({
50
55
  copyMarkdownLabel,
51
56
  copyMarkdownCopiedLabel,
52
57
  openDocs,
58
+ viewMarkdown,
53
59
  providers,
54
60
  openDocsTarget,
55
61
  openDocsPrompt,
@@ -57,6 +63,7 @@ declare function PageActions({
57
63
  variant,
58
64
  githubFileUrl,
59
65
  analytics,
66
+ askAi,
60
67
  connectMcp,
61
68
  installSkills
62
69
  }: PageActionsProps): react_jsx_runtime0.JSX.Element | null;
@@ -3,6 +3,7 @@
3
3
  import { emitClientAnalyticsEvent } from "./client-analytics.mjs";
4
4
  import { resolveOpenDocsProviderIcon, resolveOpenDocsProviders } from "./open-docs-providers.mjs";
5
5
  import { sanitizeIconHtml } from "./safe-icon-html.mjs";
6
+ import { PageActionsMenu } from "./page-actions-menu.mjs";
6
7
  import { useCallback, useEffect, useRef, useState } from "react";
7
8
  import { usePathname } from "fumadocs-core/framework";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -170,7 +171,7 @@ function currentPageTitle() {
170
171
  const title = document.querySelector("#nd-page h1") ?? document.querySelector("article h1") ?? document.querySelector("h1");
171
172
  return title?.innerText?.trim() || title?.textContent?.trim() || "";
172
173
  }
173
- function PageActions({ copyMarkdown, copyMarkdownFormat = "markdown", copyMarkdownIncludeTitle = false, copyMarkdownLabel = "Copy page", copyMarkdownCopiedLabel = "Copied!", openDocs, providers, openDocsTarget = DEFAULT_OPEN_DOCS_TARGET, openDocsPrompt = DEFAULT_OPEN_DOCS_PROMPT, alignment = "left", variant = "default", githubFileUrl, analytics = false, connectMcp, installSkills }) {
174
+ function PageActions({ copyMarkdown, copyMarkdownFormat = "markdown", copyMarkdownIncludeTitle = false, copyMarkdownLabel = "Copy page", copyMarkdownCopiedLabel = "Copied!", openDocs, viewMarkdown = false, providers, openDocsTarget = DEFAULT_OPEN_DOCS_TARGET, openDocsPrompt = DEFAULT_OPEN_DOCS_PROMPT, alignment = "left", variant = "default", githubFileUrl, analytics = false, askAi = true, connectMcp, installSkills }) {
174
175
  const [copied, setCopied] = useState(false);
175
176
  const [dropdownOpen, setDropdownOpen] = useState(false);
176
177
  const [mcpOpen, setMcpOpen] = useState(false);
@@ -309,7 +310,56 @@ function PageActions({ copyMarkdown, copyMarkdownFormat = "markdown", copyMarkdo
309
310
  setSkillsOpen(false);
310
311
  setCopied(false);
311
312
  }, [pathname]);
312
- if (variant !== "rail" && !copyMarkdown && !openDocs && !connectMcp && !installSkills) return null;
313
+ if (variant !== "rail" && !copyMarkdown && !openDocs && !viewMarkdown && !connectMcp && !installSkills) return null;
314
+ if (variant === "menu") {
315
+ const endpoint = connectMcp ? resolveAbsoluteUrl(connectMcp.endpoint ?? "/mcp") : void 0;
316
+ const items = [];
317
+ if (copyMarkdown) items.push({
318
+ key: "copy",
319
+ label: copyMarkdownLabel,
320
+ icon: /* @__PURE__ */ jsx(CopyIcon, {}),
321
+ onSelect: () => void handleCopyMarkdown()
322
+ });
323
+ if (viewMarkdown) items.push({
324
+ key: "markdown",
325
+ label: "View as Markdown",
326
+ icon: /* @__PURE__ */ jsx(FileTextIcon, {}),
327
+ href: markdownHref
328
+ });
329
+ if (openDocs) for (const provider of resolvedProviders) {
330
+ const iconHtml = sanitizeIconHtml(provider.iconHtml ?? resolveOpenDocsProviderIcon(provider.name));
331
+ items.push({
332
+ key: `open:${provider.name}`,
333
+ label: `Open in ${provider.name}`,
334
+ icon: iconHtml ? /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: iconHtml } }) : void 0,
335
+ onSelect: () => handleOpen(provider)
336
+ });
337
+ }
338
+ if (endpoint) items.push({
339
+ key: "mcp",
340
+ label: "Copy MCP server URL",
341
+ icon: /* @__PURE__ */ jsx(CopyIcon, {}),
342
+ onSelect: () => void copySetup("mcp:menu", endpoint)
343
+ });
344
+ if (installSkills) items.push({
345
+ key: "skills",
346
+ label: installSkills.label ?? "Copy skills install command",
347
+ icon: /* @__PURE__ */ jsx(CopyIcon, {}),
348
+ onSelect: () => void copySetup("skills:menu", installSkills.command ?? `npx skills add ${window.location.origin}`)
349
+ });
350
+ const status = copied ? copyMarkdownCopiedLabel : copiedSetup === "mcp:menu" ? "Copied MCP server URL" : copiedSetup === "skills:menu" ? "Copied install command" : "";
351
+ return /* @__PURE__ */ jsxs("div", {
352
+ className: "fd-page-actions fd-page-actions-menu-root",
353
+ "data-page-actions": true,
354
+ "data-page-actions-variant": "menu",
355
+ "data-actions-alignment": alignment,
356
+ children: [/* @__PURE__ */ jsx(PageActionsMenu, { items }), /* @__PURE__ */ jsx("span", {
357
+ className: "fd-page-actions-menu-status",
358
+ role: "status",
359
+ children: status
360
+ })]
361
+ });
362
+ }
313
363
  if (variant === "rail") return /* @__PURE__ */ jsxs("div", {
314
364
  className: "fd-page-actions fd-page-actions-rail",
315
365
  "data-page-actions": true,
@@ -324,7 +374,7 @@ function PageActions({ copyMarkdown, copyMarkdownFormat = "markdown", copyMarkdo
324
374
  "data-copy-markdown-include-title": copyMarkdownIncludeTitle || void 0,
325
375
  children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}), /* @__PURE__ */ jsx("span", { children: copied ? copyMarkdownCopiedLabel : copyMarkdownLabel })]
326
376
  }),
327
- openDocs && /* @__PURE__ */ jsxs("a", {
377
+ (openDocs || viewMarkdown) && /* @__PURE__ */ jsxs("a", {
328
378
  className: "fd-page-action-btn",
329
379
  href: markdownHref,
330
380
  target: "_blank",
@@ -338,7 +388,7 @@ function PageActions({ copyMarkdown, copyMarkdownFormat = "markdown", copyMarkdo
338
388
  rel: "noreferrer",
339
389
  children: [/* @__PURE__ */ jsx(GitHubIcon, {}), /* @__PURE__ */ jsx("span", { children: "Edit on GitHub" })]
340
390
  }),
341
- /* @__PURE__ */ jsxs("button", {
391
+ askAi && /* @__PURE__ */ jsxs("button", {
342
392
  type: "button",
343
393
  onClick: handleAskAI,
344
394
  className: "fd-page-action-btn",
@@ -372,6 +422,13 @@ function PageActions({ copyMarkdown, copyMarkdownFormat = "markdown", copyMarkdo
372
422
  "data-copy-markdown-include-title": copyMarkdownIncludeTitle || void 0,
373
423
  children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}), /* @__PURE__ */ jsx("span", { children: copied ? copyMarkdownCopiedLabel : copyMarkdownLabel })]
374
424
  }),
425
+ viewMarkdown && /* @__PURE__ */ jsxs("a", {
426
+ className: "fd-page-action-btn",
427
+ href: markdownHref,
428
+ target: "_blank",
429
+ rel: "noreferrer",
430
+ children: [/* @__PURE__ */ jsx(FileTextIcon, {}), /* @__PURE__ */ jsx("span", { children: "View as Markdown" })]
431
+ }),
375
432
  openDocs && resolvedProviders.length > 0 && /* @__PURE__ */ jsxs("div", {
376
433
  ref: dropdownRef,
377
434
  className: "fd-page-action-dropdown",
@@ -86,6 +86,9 @@ declare const ShadcnUIDefaults: {
86
86
  sidebar: {
87
87
  style: "default";
88
88
  };
89
+ page: {
90
+ generatedTitle: boolean;
91
+ };
89
92
  components: {
90
93
  Callout: {
91
94
  variant: string;
@@ -89,6 +89,7 @@ const ShadcnUIDefaults = {
89
89
  darkTheme: "vesper"
90
90
  },
91
91
  sidebar: { style: "default" },
92
+ page: { generatedTitle: true },
92
93
  components: {
93
94
  Callout: {
94
95
  variant: "soft",
@@ -32,6 +32,8 @@ interface TanstackDocsLayoutProps {
32
32
  /** Framework label included with privacy-preserving maintainer page-view telemetry. */
33
33
  telemetryFramework?: DocsTelemetryFramework;
34
34
  locale?: string;
35
+ /** Frontmatter title rendered as the page heading; resolve it with `resolveGeneratedPageTitle`. */
36
+ generatedTitle?: string;
35
37
  description?: string;
36
38
  descriptionInBody?: boolean;
37
39
  readingTime?: number | null;
@@ -54,6 +56,7 @@ declare function TanstackDocsLayout({
54
56
  browserRuntime,
55
57
  telemetryFramework,
56
58
  locale,
59
+ generatedTitle,
57
60
  description,
58
61
  descriptionInBody,
59
62
  readingTime,
@@ -4,9 +4,11 @@ import { escapeJsonLdForScript } from "./json-ld.mjs";
4
4
  import { DocsPageClient } from "./docs-page-client.mjs";
5
5
  import { resolveDocsCloudAIClientRequest } from "./docs-cloud-ai-client.mjs";
6
6
  import { DocsCommandSearch } from "./docs-command-search.mjs";
7
+ import { resolveTocPageActions } from "./page-actions-config.mjs";
7
8
  import { resolveReadingTimeOptions } from "./reading-time-options.mjs";
8
9
  import { SidebarSearchWithAI } from "./sidebar-search-ai.mjs";
9
10
  import { LocaleThemeControl } from "./locale-theme-control.mjs";
11
+ import { renderLayoutChrome, resolveLayoutContainerProps, resolveSidebarNavLinks, resolveSidebarNavTitle } from "./layout-chrome.mjs";
10
12
  import { DocsAIFeatures } from "./docs-ai-features.mjs";
11
13
  import { TabletSidebarBridge } from "./tablet-sidebar-bridge.mjs";
12
14
  import { DocsLayout } from "fumadocs-ui/layouts/docs";
@@ -240,7 +242,7 @@ function resolveFeedbackConfig(feedback) {
240
242
  function ForcedThemeScript({ theme }) {
241
243
  return /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: `document.documentElement.classList.remove('light','dark');document.documentElement.classList.add('${theme === "light" || theme === "dark" ? theme : "light"}');` } });
242
244
  }
243
- function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFramework, locale, description, descriptionInBody, readingTime, lastModified, previousPage, nextPage, structuredData, editOnGithubUrl, children }) {
245
+ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFramework, locale, generatedTitle, description, descriptionInBody, readingTime, lastModified, previousPage, nextPage, structuredData, editOnGithubUrl, children }) {
244
246
  const tocConfig = config.theme?.ui?.layout?.toc;
245
247
  const tocEnabled = tocConfig?.enabled !== false;
246
248
  const tocStyle = tocConfig?.style;
@@ -278,7 +280,7 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
278
280
  const llmsTxtEnabled = resolveEnabledByDefault(config.llmsTxt);
279
281
  const feedbackConfig = resolveFeedbackConfig(config.feedback);
280
282
  const staticExport = !!config.staticExport;
281
- const browserContainerProps = browserRuntime ? { "data-fd-browser-adapter": "" } : void 0;
283
+ const containerProps = resolveLayoutContainerProps(config, browserRuntime ? { "data-fd-browser-adapter": "" } : void 0);
282
284
  const openDocsConfig = pageActions?.openDocs && typeof pageActions.openDocs === "object" ? pageActions.openDocs : void 0;
283
285
  const openDocsProviders = resolveOpenDocsProviders(openDocsConfig?.providers, {
284
286
  target: openDocsConfig?.target,
@@ -332,10 +334,18 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
332
334
  collapsible: sidebarProps.collapsible !== false,
333
335
  flat: !!sidebarFlat
334
336
  });
337
+ const chrome = renderLayoutChrome(config, {
338
+ navTitle,
339
+ navUrl,
340
+ search: !staticExport,
341
+ askAI: aiEnabled && aiMode === "sidebar-icon",
342
+ themeToggle: themeSwitch.enabled !== false && { mode: themeSwitch.mode }
343
+ });
344
+ const navLinks = resolveSidebarNavLinks(config);
335
345
  const layout = /* @__PURE__ */ jsxs(DocsLayout, {
336
346
  tree: resolvedTree,
337
347
  nav: {
338
- title: navTitle,
348
+ title: resolveSidebarNavTitle(config, navTitle),
339
349
  url: navUrl
340
350
  },
341
351
  themeSwitch: locale && i18n?.locales ? {
@@ -343,7 +353,8 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
343
353
  enabled: false
344
354
  } : themeSwitch,
345
355
  sidebar: finalSidebarProps,
346
- containerProps: browserContainerProps,
356
+ containerProps,
357
+ ...navLinks ? { links: navLinks } : {},
347
358
  ...aiMode === "sidebar-icon" && aiEnabled ? { searchToggle: { components: { lg: /* @__PURE__ */ jsx(SidebarSearchWithAI, {}) } } } : {},
348
359
  children: [
349
360
  /* @__PURE__ */ jsx(ColorStyle, { colors }),
@@ -392,6 +403,7 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
392
403
  copyMarkdownLabel: copyMarkdownConfig?.label,
393
404
  copyMarkdownCopiedLabel: copyMarkdownConfig?.copiedLabel,
394
405
  openDocs: openDocsEnabled,
406
+ viewMarkdown: pageActions?.viewMarkdown === true,
395
407
  openDocsProviders,
396
408
  openDocsTarget: openDocsConfig?.target,
397
409
  openDocsPrompt: openDocsConfig?.prompt,
@@ -399,6 +411,11 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
399
411
  installSkills,
400
412
  pageActionsPosition,
401
413
  pageActionsAlignment,
414
+ pageActionsVariant: pageActions?.variant ?? "buttons",
415
+ tocActions: resolveTocPageActions(pageActions?.toc),
416
+ tocAskAi: pageActions?.askAi !== false,
417
+ footer: config.footer,
418
+ titlePager: pageActions?.pager === true,
402
419
  editOnGithubUrl,
403
420
  lastUpdatedEnabled,
404
421
  lastUpdatedLabel,
@@ -410,6 +427,7 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
410
427
  readingTimeFormat: readingTimeOptions.format,
411
428
  readingTime: typeof readingTime === "number" ? readingTime : void 0,
412
429
  llmsTxtEnabled,
430
+ generatedTitle,
413
431
  description,
414
432
  descriptionInBody,
415
433
  feedbackEnabled: feedbackConfig.enabled,
@@ -429,11 +447,15 @@ function TanstackDocsLayout({ config, tree, browserRuntime = false, telemetryFra
429
447
  })
430
448
  ]
431
449
  });
432
- if (!structuredData) return layout;
433
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("script", {
434
- type: "application/ld+json",
435
- dangerouslySetInnerHTML: { __html: escapeJsonLdForScript(structuredData) }
436
- }), layout] });
450
+ if (!structuredData && !chrome) return layout;
451
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
452
+ structuredData && /* @__PURE__ */ jsx("script", {
453
+ type: "application/ld+json",
454
+ dangerouslySetInnerHTML: { __html: escapeJsonLdForScript(structuredData) }
455
+ }),
456
+ chrome,
457
+ layout
458
+ ] });
437
459
  }
438
460
 
439
461
  //#endregion
@@ -0,0 +1,107 @@
1
+ "use client";
2
+
3
+ import { usePathname } from "fumadocs-core/framework";
4
+ import Link from "fumadocs-core/link";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { ThemeSwitch } from "fumadocs-ui/layouts/shared/slots/theme-switch";
7
+
8
+ //#region src/top-header.tsx
9
+ function isLinkActive(href, pathname) {
10
+ if (/^\w+:|^\/\//.test(href)) return void 0;
11
+ const target = href.replace(/[?#].*$/, "").replace(/\/+$/, "") || "/";
12
+ const current = pathname.replace(/\/+$/, "") || "/";
13
+ if (current === target) return "page";
14
+ if (target !== "/" && current.startsWith(`${target}/`)) return "section";
15
+ }
16
+ /** Site header spanning the page, rendered when the theme sets `ui.layout.header.placement: "top"`. */
17
+ function DocsTopHeader({ title, titleUrl, links, search, askAI, themeToggle, themeName, height }) {
18
+ const pathname = usePathname();
19
+ const style = height ? { "--fd-top-header-height": `${height}px` } : void 0;
20
+ return /* @__PURE__ */ jsxs("header", {
21
+ className: "fd-top-header",
22
+ "data-fd-theme": themeName,
23
+ style,
24
+ children: [typeof title === "function" ? title({ className: "fd-top-header-title" }) : /* @__PURE__ */ jsx(Link, {
25
+ href: titleUrl,
26
+ className: "fd-top-header-title",
27
+ children: title
28
+ }), /* @__PURE__ */ jsxs("div", {
29
+ className: "fd-top-header-controls",
30
+ children: [
31
+ search && /* @__PURE__ */ jsxs("button", {
32
+ type: "button",
33
+ className: "fd-top-header-search",
34
+ "aria-label": "Search documentation",
35
+ "aria-keyshortcuts": "Meta+K Control+K",
36
+ onClick: () => window.dispatchEvent(new CustomEvent("fd-open-search")),
37
+ children: [
38
+ /* @__PURE__ */ jsxs("svg", {
39
+ "aria-hidden": "true",
40
+ width: "16",
41
+ height: "16",
42
+ viewBox: "0 0 24 24",
43
+ fill: "none",
44
+ stroke: "currentColor",
45
+ strokeWidth: "2",
46
+ strokeLinecap: "round",
47
+ strokeLinejoin: "round",
48
+ children: [/* @__PURE__ */ jsx("circle", {
49
+ cx: "11",
50
+ cy: "11",
51
+ r: "8"
52
+ }), /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" })]
53
+ }),
54
+ /* @__PURE__ */ jsx("span", { children: "Search" }),
55
+ /* @__PURE__ */ jsx("kbd", {
56
+ "aria-hidden": "true",
57
+ children: "⌘K"
58
+ })
59
+ ]
60
+ }),
61
+ askAI && /* @__PURE__ */ jsx("button", {
62
+ type: "button",
63
+ className: "fd-top-header-ask-ai",
64
+ "aria-label": "Ask AI",
65
+ onClick: () => window.dispatchEvent(new CustomEvent("fd-open-ai")),
66
+ children: /* @__PURE__ */ jsxs("svg", {
67
+ "aria-hidden": "true",
68
+ width: "16",
69
+ height: "16",
70
+ viewBox: "0 0 24 24",
71
+ fill: "none",
72
+ stroke: "currentColor",
73
+ strokeWidth: "2",
74
+ strokeLinecap: "round",
75
+ strokeLinejoin: "round",
76
+ children: [
77
+ /* @__PURE__ */ jsx("path", { d: "M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z" }),
78
+ /* @__PURE__ */ jsx("path", { d: "M20 3v4" }),
79
+ /* @__PURE__ */ jsx("path", { d: "M22 5h-4" })
80
+ ]
81
+ })
82
+ }),
83
+ links.length > 0 && /* @__PURE__ */ jsx("nav", {
84
+ className: "fd-top-header-links",
85
+ "aria-label": "Site",
86
+ children: links.map((link) => {
87
+ const active = isLinkActive(link.href, pathname);
88
+ return /* @__PURE__ */ jsx(Link, {
89
+ href: link.href,
90
+ external: link.external === true,
91
+ "data-active": active ? "true" : void 0,
92
+ "aria-current": active === "page" ? "page" : void 0,
93
+ children: link.label
94
+ }, `${link.href}:${link.label}`);
95
+ })
96
+ }),
97
+ themeToggle && /* @__PURE__ */ jsx(ThemeSwitch, {
98
+ mode: themeToggle.mode,
99
+ className: "fd-top-header-theme-toggle"
100
+ })
101
+ ]
102
+ })]
103
+ });
104
+ }
105
+
106
+ //#endregion
107
+ export { DocsTopHeader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.2.138",
3
+ "version": "0.2.139-beta.1",
4
4
  "description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
5
5
  "keywords": [
6
6
  "docs",
@@ -162,13 +162,13 @@
162
162
  "tsdown": "^0.20.3",
163
163
  "typescript": "^5.9.3",
164
164
  "vitest": "^4.1.8",
165
- "@farming-labs/docs": "0.2.138"
165
+ "@farming-labs/docs": "0.2.139-beta.1"
166
166
  },
167
167
  "peerDependencies": {
168
168
  "next": ">=16.0.0",
169
169
  "react": ">=19.2.0",
170
170
  "react-dom": ">=19.2.0",
171
- "@farming-labs/docs": "^0.2.138"
171
+ "@farming-labs/docs": "^0.2.139-beta.1"
172
172
  },
173
173
  "peerDependenciesMeta": {
174
174
  "next": {