@farming-labs/theme 0.2.138 → 0.2.139-beta.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.
@@ -7,18 +7,20 @@ import { DocsPageClient } from "./docs-page-client.mjs";
7
7
  import { DocsAIFeatures } from "./docs-ai-features-lazy.mjs";
8
8
  import { resolveDocsCloudAIClientRequest } from "./docs-cloud-ai-client.mjs";
9
9
  import { DocsCommandSearch } from "./docs-command-search.mjs";
10
+ import { resolveTocPageActions } from "./page-actions-config.mjs";
10
11
  import { resolveReadingTimeOptions } from "./reading-time-options.mjs";
11
12
  import { resolvePageReadingTime } from "./reading-time.mjs";
12
13
  import { SidebarSearchWithAI } from "./sidebar-search-ai.mjs";
13
14
  import { LocaleThemeControl } from "./locale-theme-control.mjs";
14
15
  import { createDocsContentReader } from "./docs-content-reader.mjs";
16
+ import { renderLayoutChrome, resolveLayoutContainerProps, resolveSidebarNavLinks, resolveSidebarNavTitle } from "./layout-chrome.mjs";
15
17
  import fs from "node:fs";
16
18
  import path from "node:path";
17
19
  import { DocsLayout } from "fumadocs-ui/layouts/docs";
18
20
  import { Suspense, cloneElement, isValidElement } from "react";
19
- import { applySidebarFolderIndexBehavior, buildPageOpenGraph, buildPageTwitter, createDocsSitemapLastmodResolver, normalizePageAgentFrontmatter, resolveChangelogConfig, resolveDocsAnalyticsConfig, resolveDocsAudienceMdxContent, resolveDocsMetadataBaseUrl, resolvePageSidebarFolderIndexBehavior, toDocsMarkdownUrl } from "@farming-labs/docs";
21
+ import { applySidebarFolderIndexBehavior, buildPageOpenGraph, buildPageTwitter, createDocsSitemapLastmodResolver, normalizePageAgentFrontmatter, resolveChangelogConfig, resolveDocsAnalyticsConfig, resolveDocsAudienceMdxContent, resolveDocsMetadataBaseUrl, resolveGeneratedPageTitle, resolvePageSidebarFolderIndexBehavior, toDocsMarkdownUrl } from "@farming-labs/docs";
20
22
  import { readDocsSitemapManifest } from "@farming-labs/docs/runtime";
21
- import { jsx, jsxs } from "react/jsx-runtime";
23
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
22
24
 
23
25
  //#region src/docs-layout.tsx
24
26
  function getNextAppDir(root) {
@@ -49,25 +51,6 @@ function readFrontmatter(reader, filePath) {
49
51
  return {};
50
52
  }
51
53
  }
52
- function hasAuthoredPageTitle(content) {
53
- const lines = content.split(/\r?\n/);
54
- let fence;
55
- let previousTextLine = "";
56
- for (const line of lines) {
57
- const fenceMatch = line.match(/^\s*(`{3,}|~{3,})/);
58
- if (fenceMatch) {
59
- const marker = fenceMatch[1]?.[0];
60
- fence = fence === marker ? void 0 : fence ?? marker;
61
- previousTextLine = "";
62
- continue;
63
- }
64
- if (fence) continue;
65
- if (/^ {0,3}#(?:\s+|$)/.test(line) || /^\s*<h1(?:\s|>)/i.test(line)) return true;
66
- if (previousTextLine && /^ {0,3}=+\s*$/.test(line)) return true;
67
- previousTextLine = line.trim() && !line.trimStart().startsWith("<") ? line : "";
68
- }
69
- return false;
70
- }
71
54
  function resolveSidebarFolderName(themeName, slug, pageTitle) {
72
55
  if (themeName !== "shadcn" || pageTitle.trim().toLowerCase() !== "introduction") return pageTitle;
73
56
  return slug.split(/[-_]/).filter(Boolean).map((part) => part[0]?.toUpperCase() + part.slice(1)).join(" ");
@@ -476,7 +459,8 @@ function buildPageMaps(config, ctx, reader, manifest, options) {
476
459
  const title = typeof data.title === "string" ? data.title : slugParts.at(-1)?.replace(/-/g, " ") || "Documentation";
477
460
  const description = typeof data.description === "string" ? data.description : void 0;
478
461
  const manifestLastmod = resolveManifestLastmod(resolveLastmod, ctx, route);
479
- if (config.theme?.name === "shadcn" && typeof data.title === "string" && !hasAuthoredPageTitle(content)) generatedTitleMap[route] = data.title;
462
+ const generatedTitle = resolveGeneratedPageTitle(config.theme, data, content);
463
+ if (generatedTitle !== void 0) generatedTitleMap[route] = generatedTitle;
480
464
  if (fileName === "page.mdx") {
481
465
  if (dateFormatter) lastModifiedMap[route] = dateFormatter.format(manifestLastmod ? /* @__PURE__ */ new Date(`${manifestLastmod}T00:00:00`) : modifiedAt);
482
466
  if (description) descriptionMap[route] = description;
@@ -748,6 +732,7 @@ function createDocsLayout(config, options) {
748
732
  const githubUrl = typeof githubRaw === "string" ? githubRaw.replace(/\/$/, "") : githubRaw?.url.replace(/\/$/, "");
749
733
  const githubBranch = typeof githubRaw === "object" ? githubRaw.branch ?? "main" : "main";
750
734
  const githubDirectory = typeof githubRaw === "object" ? githubRaw.directory?.replace(/^\/|\/$/g, "") : void 0;
735
+ const githubEditUrl = typeof githubRaw === "object" ? githubRaw.editUrl : void 0;
751
736
  const contentDir = config.contentDir;
752
737
  const staticExport = !!config.staticExport;
753
738
  const aiConfig = config.ai;
@@ -817,10 +802,18 @@ function createDocsLayout(config, options) {
817
802
  collapsible: sidebarProps.collapsible !== false,
818
803
  flat: !!sidebarFlat
819
804
  });
820
- return /* @__PURE__ */ jsxs(DocsLayout, {
805
+ const chrome = renderLayoutChrome(config, {
806
+ navTitle,
807
+ navUrl,
808
+ search: !staticExport,
809
+ askAI: aiEnabled && aiMode === "sidebar-icon",
810
+ themeToggle: themeSwitch.enabled !== false && { mode: themeSwitch.mode }
811
+ });
812
+ const navLinks = resolveSidebarNavLinks(config);
813
+ const layout = /* @__PURE__ */ jsxs(DocsLayout, {
821
814
  tree: localizedTree,
822
815
  nav: {
823
- title: navTitle,
816
+ title: resolveSidebarNavTitle(config, navTitle),
824
817
  url: navUrl
825
818
  },
826
819
  themeSwitch: i18n ? {
@@ -828,6 +821,8 @@ function createDocsLayout(config, options) {
828
821
  enabled: false
829
822
  } : themeSwitch,
830
823
  sidebar: finalSidebarProps,
824
+ containerProps: resolveLayoutContainerProps(config),
825
+ ...navLinks ? { links: navLinks } : {},
831
826
  ...aiMode === "sidebar-icon" && aiEnabled ? { searchToggle: { components: { lg: /* @__PURE__ */ jsx(SidebarSearchWithAI, {}) } } } : {},
832
827
  children: [
833
828
  /* @__PURE__ */ jsx(ColorStyle, { colors }),
@@ -880,6 +875,7 @@ function createDocsLayout(config, options) {
880
875
  copyMarkdownLabel: copyMarkdownConfig?.label,
881
876
  copyMarkdownCopiedLabel: copyMarkdownConfig?.copiedLabel,
882
877
  openDocs: openDocsEnabled,
878
+ viewMarkdown: pageActions?.viewMarkdown === true,
883
879
  openDocsProviders,
884
880
  openDocsTarget: openDocsConfig?.target,
885
881
  openDocsPrompt: openDocsConfig?.prompt,
@@ -887,10 +883,16 @@ function createDocsLayout(config, options) {
887
883
  installSkills,
888
884
  pageActionsPosition,
889
885
  pageActionsAlignment,
886
+ pageActionsVariant: pageActions?.variant ?? "buttons",
887
+ tocActions: resolveTocPageActions(pageActions?.toc),
888
+ tocAskAi: pageActions?.askAi !== false,
889
+ footer: config.footer,
890
+ titlePager: pageActions?.pager === true,
890
891
  githubUrl,
891
892
  contentDir,
892
893
  githubBranch,
893
894
  githubDirectory,
895
+ githubEditUrl,
894
896
  pageMetadata,
895
897
  lastUpdatedEnabled,
896
898
  lastUpdatedLabel,
@@ -915,6 +917,8 @@ function createDocsLayout(config, options) {
915
917
  })
916
918
  ]
917
919
  });
920
+ if (!chrome) return layout;
921
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [chrome, layout] });
918
922
  };
919
923
  }
920
924
  /** Resolve `boolean | { enabled?: boolean }` to a simple boolean. */
@@ -1,3 +1,4 @@
1
+ import { ResolvedTocPageActions } from "./page-actions-config.mjs";
1
2
  import { DocsStructuredDataPages } from "./page-structured-data.mjs";
2
3
  import { DocsPageMetadata } from "./page-metadata.mjs";
3
4
  import { ReactNode } from "react";
@@ -38,13 +39,21 @@ interface DocsPageClientProps {
38
39
  copyMarkdownLabel?: string;
39
40
  copyMarkdownCopiedLabel?: string;
40
41
  openDocs?: boolean;
42
+ /** Link to the page's Markdown (`.md`) route. */
43
+ viewMarkdown?: boolean;
41
44
  openDocsProviders?: SerializedProvider[];
42
45
  openDocsTarget?: "markdown" | "page" | "source" | "github";
43
46
  openDocsPrompt?: string;
44
47
  connectMcp?: PageActionConnectMcpConfig;
45
48
  installSkills?: PageActionInstallSkillsConfig;
46
49
  /** Where to render page actions relative to the title */
47
- pageActionsPosition?: "above-title" | "below-title" | "toc";
50
+ pageActionsPosition?: "above-title" | "below-title" | "title" | "toc";
51
+ /** `menu` collects the title, below-title or above-title actions behind one "…" trigger. */
52
+ pageActionsVariant?: "buttons" | "menu";
53
+ /** Actions in the table-of-contents rail alongside the actions at `pageActionsPosition`. */
54
+ tocActions?: ResolvedTocPageActions;
55
+ /** The table-of-contents rail's "Ask AI" button. */
56
+ tocAskAi?: boolean;
48
57
  /** Horizontal alignment of page action buttons */
49
58
  pageActionsAlignment?: "left" | "right";
50
59
  /** GitHub repository URL (e.g. "https://github.com/user/repo") */
@@ -55,6 +64,8 @@ interface DocsPageClientProps {
55
64
  githubBranch?: string;
56
65
  /** Subdirectory in the repo where the docs site lives (for monorepos) */
57
66
  githubDirectory?: string;
67
+ /** Edit link template; `{path}` is the page's source path relative to the repo. */
68
+ githubEditUrl?: string;
58
69
  /** Direct GitHub URL override for the current page. */
59
70
  editOnGithubUrl?: string;
60
71
  /** Map of pathname → formatted last-modified date string */
@@ -69,6 +80,8 @@ interface DocsPageClientProps {
69
80
  readingTimeFormat?: ReadingTimeFormat;
70
81
  previousPage?: PageNavigationItem | null;
71
82
  nextPage?: PageNavigationItem | null;
83
+ /** Previous/next icon links in the page title row. Without explicit pages they come from the page tree. */
84
+ titlePager?: boolean;
72
85
  /** Map of pathname → serialized Schema.org JSON-LD. */
73
86
  structuredDataMap?: Record<string, string>;
74
87
  /** Compact page fields; shared schema and breadcrumbs expand only for the active page. */
@@ -90,6 +103,8 @@ interface DocsPageClientProps {
90
103
  llmsTxtEnabled?: boolean;
91
104
  /** Frontmatter titles for pages whose MDX body does not author an h1 */
92
105
  generatedTitleMap?: Record<string, string>;
106
+ /** Generated page title for the current page (overrides generatedTitleMap) */
107
+ generatedTitle?: string;
93
108
  /** Map of pathname → frontmatter description */
94
109
  descriptionMap?: Record<string, string>;
95
110
  /** Frontmatter description to display below the page title (overrides descriptionMap) */
@@ -110,6 +125,8 @@ interface DocsPageClientProps {
110
125
  analytics?: boolean;
111
126
  telemetry?: boolean | DocsTelemetryConfig;
112
127
  telemetryFramework?: DocsTelemetryFramework;
128
+ /** Rendered at the end of the page content area, after the page navigation. */
129
+ footer?: ReactNode;
113
130
  children: ReactNode;
114
131
  }
115
132
  declare function DocsPageClient({
@@ -128,17 +145,22 @@ declare function DocsPageClient({
128
145
  copyMarkdownLabel,
129
146
  copyMarkdownCopiedLabel,
130
147
  openDocs,
148
+ viewMarkdown,
131
149
  openDocsProviders,
132
150
  openDocsTarget,
133
151
  openDocsPrompt,
134
152
  connectMcp,
135
153
  installSkills,
136
154
  pageActionsPosition,
155
+ pageActionsVariant,
156
+ tocActions,
157
+ tocAskAi,
137
158
  pageActionsAlignment,
138
159
  githubUrl,
139
160
  contentDir,
140
161
  githubBranch,
141
162
  githubDirectory,
163
+ githubEditUrl,
142
164
  editOnGithubUrl,
143
165
  lastModifiedMap,
144
166
  lastModified: lastModifiedProp,
@@ -147,6 +169,7 @@ declare function DocsPageClient({
147
169
  readingTimeFormat,
148
170
  previousPage,
149
171
  nextPage,
172
+ titlePager,
150
173
  structuredDataMap,
151
174
  structuredDataPages,
152
175
  structuredData: structuredDataProp,
@@ -156,6 +179,7 @@ declare function DocsPageClient({
156
179
  lastUpdatedPosition,
157
180
  llmsTxtEnabled,
158
181
  generatedTitleMap,
182
+ generatedTitle,
159
183
  descriptionMap,
160
184
  description,
161
185
  descriptionInBody,
@@ -172,6 +196,7 @@ declare function DocsPageClient({
172
196
  analytics,
173
197
  telemetry,
174
198
  telemetryFramework,
199
+ footer,
175
200
  children
176
201
  }: DocsPageClientProps): react_jsx_runtime0.JSX.Element;
177
202
  //#endregion
@@ -12,7 +12,9 @@ import { Children, Fragment, useEffect, useLayoutEffect, useState } from "react"
12
12
  import { DocsBody, DocsPage, EditOnGitHub } from "fumadocs-ui/layouts/docs/page";
13
13
  import { createPortal } from "react-dom";
14
14
  import { usePathname, useRouter } from "fumadocs-core/framework";
15
- import { emitDocsTelemetryPageViewEvent } from "@farming-labs/docs/browser";
15
+ import Link from "fumadocs-core/link";
16
+ import { useFooterItems } from "fumadocs-ui/utils/use-footer-items";
17
+ import { emitDocsTelemetryPageViewEvent, formatGithubEditUrl } from "@farming-labs/docs/browser";
16
18
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
19
 
18
20
  //#region src/docs-page-client.tsx
@@ -87,8 +89,9 @@ function PathBreadcrumb({ pathname, publicPath, locale }) {
87
89
  * Examples:
88
90
  * No directory: https://github.com/user/repo/edit/main/app/docs/cli/page.mdx
89
91
  * With directory: https://github.com/farming-labs/docs/edit/main/website/app/docs/cli/page.mdx
92
+ * With editUrl: the template with `{path}` replaced by website/app/docs/cli/page.mdx
90
93
  */
91
- function buildGithubFileUrl(githubUrl, branch, pathname, entry, locale, directory, contentDir) {
94
+ function buildGithubFileUrl(githubUrl, branch, pathname, entry, locale, directory, contentDir, editUrl) {
92
95
  const normalizedEntry = entry.replace(/^\/+|\/+$/g, "") || "docs";
93
96
  const normalizedContentDir = contentDir?.replace(/^\/+|\/+$/g, "");
94
97
  const entryParts = normalizedEntry.split("/").filter(Boolean);
@@ -97,7 +100,8 @@ function buildGithubFileUrl(githubUrl, branch, pathname, entry, locale, director
97
100
  const dirPrefix = directory ? `${directory}/` : "";
98
101
  const basePath = normalizedContentDir || `app/${normalizedEntry}`;
99
102
  const relativePath = [locale, slugParts.join("/")].filter(Boolean).join("/");
100
- return `${githubUrl}/edit/${branch}/${`${dirPrefix}${basePath}${relativePath ? `/${relativePath}` : ""}/page.mdx`}`;
103
+ const path = `${dirPrefix}${basePath}${relativePath ? `/${relativePath}` : ""}/page.mdx`;
104
+ return editUrl ? formatGithubEditUrl(editUrl, path) : `${githubUrl}/edit/${branch}/${path}`;
101
105
  }
102
106
  function localizeInternalLinks(root, locale) {
103
107
  const anchors = root.querySelectorAll("a[href]:not([data-fd-lang-localized=\"true\"])");
@@ -226,9 +230,74 @@ function scrollToHashTarget(hash) {
226
230
  target.scrollIntoView({ block: "start" });
227
231
  return true;
228
232
  }
229
- function TitleDecorations({ description, belowTitle }) {
230
- if (!description && !belowTitle) return null;
231
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [description && /* @__PURE__ */ jsx(Fragment, { children: description }, "description"), belowTitle && /* @__PURE__ */ jsx(Fragment, { children: belowTitle }, "below-title")] });
233
+ function TitleDecorations({ titleActions, description, belowTitle }) {
234
+ if (!titleActions && !description && !belowTitle) return null;
235
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
236
+ titleActions && /* @__PURE__ */ jsx(Fragment, { children: titleActions }, "title-actions"),
237
+ description && /* @__PURE__ */ jsx(Fragment, { children: description }, "description"),
238
+ belowTitle && /* @__PURE__ */ jsx(Fragment, { children: belowTitle }, "below-title")
239
+ ] });
240
+ }
241
+ function pagerLabel(direction, name) {
242
+ return typeof name === "string" || typeof name === "number" ? `${direction}: ${name}` : `${direction} page`;
243
+ }
244
+ function TitlePagerLink({ direction, item }) {
245
+ const className = `fd-title-pager-link fd-title-pager-${direction === "Previous" ? "prev" : "next"}`;
246
+ const icon = /* @__PURE__ */ jsx("svg", {
247
+ width: "16",
248
+ height: "16",
249
+ viewBox: "0 0 24 24",
250
+ fill: "none",
251
+ stroke: "currentColor",
252
+ strokeWidth: "2",
253
+ strokeLinecap: "round",
254
+ strokeLinejoin: "round",
255
+ "aria-hidden": "true",
256
+ children: /* @__PURE__ */ jsx("polyline", { points: direction === "Previous" ? "15 18 9 12 15 6" : "9 18 15 12 9 6" })
257
+ });
258
+ if (!item) return /* @__PURE__ */ jsx("span", {
259
+ className,
260
+ "data-disabled": "true",
261
+ "aria-hidden": "true",
262
+ children: icon
263
+ });
264
+ const label = pagerLabel(direction, item.name);
265
+ return /* @__PURE__ */ jsx(Link, {
266
+ href: item.url,
267
+ className,
268
+ "aria-label": label,
269
+ title: label,
270
+ children: icon
271
+ });
272
+ }
273
+ function TitlePager({ previous, next }) {
274
+ if (!previous && !next) return null;
275
+ return /* @__PURE__ */ jsxs("nav", {
276
+ className: "fd-title-pager",
277
+ "aria-label": "Previous and next page",
278
+ children: [/* @__PURE__ */ jsx(TitlePagerLink, {
279
+ direction: "Previous",
280
+ item: previous
281
+ }), /* @__PURE__ */ jsx(TitlePagerLink, {
282
+ direction: "Next",
283
+ item: next
284
+ })]
285
+ });
286
+ }
287
+ function stripUrlSuffix(url) {
288
+ const path = url.replace(/[?#].*$/, "");
289
+ return path.length > 1 ? path.replace(/\/+$/, "") : path;
290
+ }
291
+ /** Neighbors from the page tree, matching the pager Fumadocs renders at the bottom of the page. */
292
+ function TreeTitlePager({ pathname }) {
293
+ const pages = useFooterItems();
294
+ const current = stripUrlSuffix(pathname);
295
+ const index = pages.findIndex((page) => stripUrlSuffix(page.url) === current);
296
+ if (index === -1) return null;
297
+ return /* @__PURE__ */ jsx(TitlePager, {
298
+ previous: pages[index - 1],
299
+ next: pages[index + 1]
300
+ });
232
301
  }
233
302
  function ThreadlinePageControls() {
234
303
  return /* @__PURE__ */ jsxs("div", {
@@ -266,7 +335,7 @@ function findThreadlineTocActionsContainer() {
266
335
  }
267
336
  return toc.parentElement ?? toc;
268
337
  }
269
- function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, tocStyle = "default", breadcrumbEnabled = true, changelogBasePath, entry = "docs", publicPath, locale, copyMarkdown = false, copyMarkdownFormat, copyMarkdownIncludeTitle, copyMarkdownLabel, copyMarkdownCopiedLabel, openDocs = false, openDocsProviders, openDocsTarget, openDocsPrompt, connectMcp, installSkills, pageActionsPosition = "below-title", pageActionsAlignment = "left", githubUrl, contentDir, githubBranch = "main", githubDirectory, editOnGithubUrl, lastModifiedMap, lastModified: lastModifiedProp, readingTimeMap, readingTime: readingTimeProp, readingTimeFormat = "long", previousPage, nextPage, structuredDataMap, structuredDataPages, structuredData: structuredDataProp, readingTimeEnabled = false, lastUpdatedEnabled = true, lastUpdatedLabel = "Last updated", lastUpdatedPosition = "footer", llmsTxtEnabled = false, generatedTitleMap, descriptionMap, description, descriptionInBody = false, feedbackEnabled = false, feedbackQuestion, feedbackPlaceholder, feedbackRequireComment, feedbackPositiveLabel, feedbackNegativeLabel, feedbackSubmitLabel, feedbackSuccessMessage, feedbackErrorMessage, feedbackOnFeedback, analytics = false, telemetry, telemetryFramework, children }) {
338
+ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, tocStyle = "default", breadcrumbEnabled = true, changelogBasePath, entry = "docs", publicPath, locale, copyMarkdown = false, copyMarkdownFormat, copyMarkdownIncludeTitle, copyMarkdownLabel, copyMarkdownCopiedLabel, openDocs = false, viewMarkdown = false, openDocsProviders, openDocsTarget, openDocsPrompt, connectMcp, installSkills, pageActionsPosition = "below-title", pageActionsVariant = "buttons", tocActions, tocAskAi = true, pageActionsAlignment = "left", githubUrl, contentDir, githubBranch = "main", githubDirectory, githubEditUrl, editOnGithubUrl, lastModifiedMap, lastModified: lastModifiedProp, readingTimeMap, readingTime: readingTimeProp, readingTimeFormat = "long", previousPage, nextPage, titlePager = false, structuredDataMap, structuredDataPages, structuredData: structuredDataProp, readingTimeEnabled = false, lastUpdatedEnabled = true, lastUpdatedLabel = "Last updated", lastUpdatedPosition = "footer", llmsTxtEnabled = false, generatedTitleMap, generatedTitle, descriptionMap, description, descriptionInBody = false, feedbackEnabled = false, feedbackQuestion, feedbackPlaceholder, feedbackRequireComment, feedbackPositiveLabel, feedbackNegativeLabel, feedbackSubmitLabel, feedbackSuccessMessage, feedbackErrorMessage, feedbackOnFeedback, analytics = false, telemetry, telemetryFramework, footer, children }) {
270
339
  const router = useRouter();
271
340
  const fdTocStyle = tocStyle === "directional" ? "clerk" : void 0;
272
341
  const [toc, setToc] = useState([]);
@@ -283,7 +352,7 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
283
352
  const shouldShowLlmsInHeader = llmsTxtEnabled && showLlmsInHeader;
284
353
  const normalizedPath = (browserPathname || pathname).replace(/\/$/, "") || "/";
285
354
  const page = resolvePageMetadata(pageMetadata, normalizedPath);
286
- const pageTitle = generatedTitleMap?.[normalizedPath] ?? page?.generatedTitle;
355
+ const pageTitle = generatedTitle ?? generatedTitleMap?.[normalizedPath] ?? page?.generatedTitle;
287
356
  const pageDescription = description ?? descriptionMap?.[normalizedPath] ?? page?.description;
288
357
  const isChangelogRoute = !!(changelogBasePath && (normalizedPath === changelogBasePath || normalizedPath.startsWith(`${changelogBasePath}/`)));
289
358
  const matchedReadingTime = readingTimeMap?.[normalizedPath] ?? page?.readingTime;
@@ -401,13 +470,16 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
401
470
  clearTimeout(timeout);
402
471
  };
403
472
  }, [pathname, children]);
404
- const showActions = !isChangelogRoute && (copyMarkdown || openDocs || pageActionsPosition === "toc");
473
+ const showActions = !isChangelogRoute && (copyMarkdown || openDocs || viewMarkdown || pageActionsPosition === "toc");
405
474
  const showActionsBelowTitle = showActions && pageActionsPosition === "below-title";
406
475
  const showActionsAboveTitle = showActions && pageActionsPosition === "above-title";
476
+ const showActionsInTitle = showActions && pageActionsPosition === "title";
407
477
  const showActionsInToc = showActions && pageActionsPosition === "toc";
408
- const githubFileUrl = editOnGithubUrl ?? (githubUrl ? buildGithubFileUrl(githubUrl, githubBranch, pathname, entry, activeLocale, githubDirectory, contentDir) : void 0);
478
+ const actionsVariant = pageActionsVariant === "menu" ? "menu" : "default";
479
+ const showTocRail = showActionsInToc || !isChangelogRoute && !!tocActions;
480
+ const githubFileUrl = editOnGithubUrl ?? (githubUrl ? buildGithubFileUrl(githubUrl, githubBranch, pathname, entry, activeLocale, githubDirectory, contentDir, githubEditUrl) : void 0);
409
481
  useLayoutEffect(() => {
410
- if (!showActionsInToc) {
482
+ if (!showTocRail) {
411
483
  setTocActionsPortalHost(null);
412
484
  return;
413
485
  }
@@ -442,7 +514,7 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
442
514
  };
443
515
  }, [
444
516
  pathname,
445
- showActionsInToc,
517
+ showTocRail,
446
518
  toc.length
447
519
  ]);
448
520
  useLayoutEffect(() => {
@@ -495,7 +567,7 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
495
567
  children: pageDescription
496
568
  }) : void 0;
497
569
  const showReadingTimeAboveTitle = !!readingTimeBlock && showActionsAboveTitle;
498
- const showReadingTimeBelowTitle = !!readingTimeBlock && !showReadingTimeAboveTitle && (showActionsBelowTitle || showLastUpdatedBelowTitle || !showActions && pageActionsPosition === "below-title");
570
+ const showReadingTimeBelowTitle = !!readingTimeBlock && !showReadingTimeAboveTitle && (showActionsBelowTitle || showLastUpdatedBelowTitle || pageActionsPosition === "title" || !showActions && pageActionsPosition === "below-title");
499
571
  const belowTitleBlock = showLastUpdatedBelowTitle || showActionsBelowTitle || showReadingTimeBelowTitle ? /* @__PURE__ */ jsxs("div", {
500
572
  className: "fd-below-title-block not-prose",
501
573
  children: [
@@ -514,13 +586,14 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
514
586
  copyMarkdownLabel,
515
587
  copyMarkdownCopiedLabel,
516
588
  openDocs,
589
+ viewMarkdown,
517
590
  providers: openDocsProviders,
518
591
  openDocsTarget,
519
592
  openDocsPrompt,
520
593
  connectMcp,
521
594
  installSkills,
522
595
  alignment: pageActionsAlignment,
523
- variant: "default",
596
+ variant: actionsVariant,
524
597
  githubFileUrl,
525
598
  analytics
526
599
  })
@@ -528,8 +601,34 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
528
601
  showReadingTimeBelowTitle && readingTimeBlock
529
602
  ]
530
603
  }, "below-title") : void 0;
604
+ const neighborsFromTree = previousPage === void 0 && nextPage === void 0;
605
+ const titlePagerBlock = titlePager && !isChangelogRoute && (neighborsFromTree || showPageNavigation) ? neighborsFromTree ? /* @__PURE__ */ jsx(TreeTitlePager, { pathname: normalizedPath }) : /* @__PURE__ */ jsx(TitlePager, {
606
+ previous: localizedPreviousPage,
607
+ next: localizedNextPage
608
+ }) : void 0;
609
+ const titleActions = titlePagerBlock || showActionsInTitle ? /* @__PURE__ */ jsxs("div", {
610
+ className: "fd-page-title-actions not-prose",
611
+ children: [titlePagerBlock, showActionsInTitle && /* @__PURE__ */ jsx(PageActions, {
612
+ copyMarkdown,
613
+ copyMarkdownFormat,
614
+ copyMarkdownIncludeTitle,
615
+ copyMarkdownLabel,
616
+ copyMarkdownCopiedLabel,
617
+ openDocs,
618
+ viewMarkdown,
619
+ providers: openDocsProviders,
620
+ openDocsTarget,
621
+ openDocsPrompt,
622
+ connectMcp,
623
+ installSkills,
624
+ alignment: "right",
625
+ variant: actionsVariant,
626
+ githubFileUrl,
627
+ analytics
628
+ }, "actions")]
629
+ }, "title-actions") : void 0;
531
630
  const decoratedChildren = children;
532
- const needsTitleDecorationsPortal = !pageTitle && (!!titleDescription || !!belowTitleBlock);
631
+ const needsTitleDecorationsPortal = !pageTitle && (!!titleActions || !!titleDescription || !!belowTitleBlock);
533
632
  useLayoutEffect(() => {
534
633
  if (!needsTitleDecorationsPortal) {
535
634
  setTitlePortalHost(null);
@@ -583,6 +682,7 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
583
682
  pathname
584
683
  ]);
585
684
  const titleDecorations = needsTitleDecorationsPortal ? /* @__PURE__ */ jsx(TitleDecorations, {
685
+ titleActions,
586
686
  description: titleDescription,
587
687
  belowTitle: belowTitleBlock
588
688
  }) : null;
@@ -594,7 +694,13 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
594
694
  }) : null;
595
695
  const generatedPageHeader = pageTitle ? /* @__PURE__ */ jsxs("div", {
596
696
  className: "fd-generated-page-header not-prose",
597
- children: [/* @__PURE__ */ jsx("h1", {
697
+ children: [titleActions ? /* @__PURE__ */ jsxs("div", {
698
+ className: "fd-page-title-row",
699
+ children: [/* @__PURE__ */ jsx("h1", {
700
+ className: "fd-page-title",
701
+ children: pageTitle
702
+ }), titleActions]
703
+ }) : /* @__PURE__ */ jsx("h1", {
598
704
  className: "fd-page-title",
599
705
  children: pageTitle
600
706
  }), /* @__PURE__ */ jsx(TitleDecorations, {
@@ -603,15 +709,16 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
603
709
  })]
604
710
  }) : null;
605
711
  const titleControlsPortal = showActionsInToc && titleControlsPortalHost ? createPortal(/* @__PURE__ */ jsx(ThreadlinePageControls, {}), titleControlsPortalHost, "title-controls") : null;
606
- const tocActionsPortal = showActionsInToc && tocActionsPortalHost ? createPortal(/* @__PURE__ */ jsx("div", {
712
+ const tocActionsPortal = showTocRail && tocActionsPortalHost ? createPortal(/* @__PURE__ */ jsx("div", {
607
713
  className: "fd-actions-toc-portal not-prose",
608
- children: /* @__PURE__ */ jsx(PageActions, {
714
+ children: showActionsInToc ? /* @__PURE__ */ jsx(PageActions, {
609
715
  copyMarkdown,
610
716
  copyMarkdownFormat,
611
717
  copyMarkdownIncludeTitle,
612
718
  copyMarkdownLabel,
613
719
  copyMarkdownCopiedLabel,
614
720
  openDocs,
721
+ viewMarkdown,
615
722
  providers: openDocsProviders,
616
723
  openDocsTarget,
617
724
  openDocsPrompt,
@@ -620,9 +727,27 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
620
727
  alignment: "left",
621
728
  variant: "rail",
622
729
  githubFileUrl,
623
- analytics
730
+ analytics,
731
+ askAi: tocAskAi
732
+ }) : tocActions && /* @__PURE__ */ jsx(PageActions, {
733
+ copyMarkdown: tocActions.copyMarkdown,
734
+ copyMarkdownFormat,
735
+ copyMarkdownIncludeTitle,
736
+ copyMarkdownLabel,
737
+ copyMarkdownCopiedLabel,
738
+ viewMarkdown: tocActions.viewMarkdown,
739
+ alignment: "left",
740
+ variant: "rail",
741
+ githubFileUrl: tocActions.editOnGitHub ? githubFileUrl : void 0,
742
+ analytics,
743
+ askAi: tocAskAi
624
744
  })
625
745
  }), tocActionsPortalHost, "toc-actions") : null;
746
+ const fumadocsFooterEnabled = !isChangelogRoute && !showPageNavigation;
747
+ const contentFooter = footer !== void 0 && footer !== null && footer !== false ? /* @__PURE__ */ jsx("footer", {
748
+ className: "fd-page-content-footer not-prose",
749
+ children: footer
750
+ }, "content-footer") : void 0;
626
751
  const renderedChildren = Children.toArray(decoratedChildren).map((child, index) => /* @__PURE__ */ jsx(Fragment, { children: child }, `fd-rendered-child-${index}`));
627
752
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
628
753
  structuredDataJson && /* @__PURE__ */ jsx("script", {
@@ -652,7 +777,10 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
652
777
  style: fdTocStyle
653
778
  },
654
779
  breadcrumb: { enabled: false },
655
- footer: { enabled: !isChangelogRoute && !showPageNavigation },
780
+ footer: {
781
+ enabled: fumadocsFooterEnabled,
782
+ ...contentFooter && fumadocsFooterEnabled ? { children: contentFooter } : {}
783
+ },
656
784
  children: [
657
785
  effectiveBreadcrumbEnabled && /* @__PURE__ */ jsx(PathBreadcrumb, {
658
786
  pathname,
@@ -671,13 +799,14 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
671
799
  copyMarkdownLabel,
672
800
  copyMarkdownCopiedLabel,
673
801
  openDocs,
802
+ viewMarkdown,
674
803
  providers: openDocsProviders,
675
804
  openDocsTarget,
676
805
  openDocsPrompt,
677
806
  connectMcp,
678
807
  installSkills,
679
808
  alignment: pageActionsAlignment,
680
- variant: "default",
809
+ variant: actionsVariant,
681
810
  githubFileUrl,
682
811
  analytics
683
812
  })
@@ -786,7 +915,8 @@ function DocsPageClient({ pageMetadata, tocEnabled, showLlmsInHeader = false, to
786
915
  children: "Next Page"
787
916
  })]
788
917
  }) : /* @__PURE__ */ jsx("div", { "aria-hidden": "true" })]
789
- }, "page-navigation")
918
+ }, "page-navigation"),
919
+ !fumadocsFooterEnabled && contentFooter
790
920
  ]
791
921
  }, "body")
792
922
  ]
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
 
3
3
  import { useEffect, useRef, useState } from "react";
4
- import { jsx, jsxs } from "react/jsx-runtime";
5
4
  import Link from "fumadocs-core/link";
6
5
  import { Popover, PopoverContent, PopoverTrigger } from "fumadocs-ui/components/ui/popover";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
7
 
8
8
  //#region src/hover-link.tsx
9
9
  function HoverLink({ href, title, description, children, linkLabel = "Open page", previewLabel, external, prefetch, showIndicator = false, align = "center", side = "bottom", sideOffset = 12, closeDelay = 90 }) {
@@ -0,0 +1,76 @@
1
+ import { DocsTopHeader } from "./top-header.mjs";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ //#region src/layout-chrome.tsx
5
+ function isTopHeader(config) {
6
+ return config.theme?.ui?.layout?.header?.placement === "top";
7
+ }
8
+ function topHeaderHeight(config) {
9
+ const height = config.theme?.ui?.layout?.header?.height;
10
+ return typeof height === "number" && height > 0 ? height : void 0;
11
+ }
12
+ function resolveNavLinks(config) {
13
+ const links = config.nav?.links;
14
+ if (!Array.isArray(links)) return [];
15
+ return links.filter((link) => !!link && typeof link.label === "string" && typeof link.href === "string");
16
+ }
17
+ /** Attributes on the layout root (`#nd-docs-layout`) that theme CSS selects on. */
18
+ function resolveLayoutContainerProps(config, adapterProps) {
19
+ const themeName = config.theme?.name;
20
+ const props = {
21
+ ...themeName ? { "data-fd-theme": themeName } : {},
22
+ ...adapterProps
23
+ };
24
+ if (isTopHeader(config)) {
25
+ const height = topHeaderHeight(config);
26
+ props["data-fd-header"] = "top";
27
+ props.style = {
28
+ "--fd-docs-row-1": "calc(var(--fd-banner-height, 0px) + var(--fd-top-header-offset, 0px))",
29
+ ...height ? { "--fd-top-header-height": `${height}px` } : {}
30
+ };
31
+ }
32
+ return Object.keys(props).length > 0 ? props : void 0;
33
+ }
34
+ /** `nav.links` as sidebar link items; the top header hides them from the desktop sidebar. */
35
+ function resolveSidebarNavLinks(config) {
36
+ const links = resolveNavLinks(config);
37
+ if (links.length === 0) return void 0;
38
+ return links.map((link) => ({
39
+ text: /* @__PURE__ */ jsx("span", {
40
+ className: "fd-nav-link",
41
+ children: link.label
42
+ }),
43
+ url: link.href,
44
+ external: link.external === true
45
+ }));
46
+ }
47
+ /** The nav title, marked so the top header can hide its sidebar copy on desktop. */
48
+ function resolveSidebarNavTitle(config, title) {
49
+ return isTopHeader(config) ? /* @__PURE__ */ jsx("span", {
50
+ className: "fd-nav-title",
51
+ children: title
52
+ }) : title;
53
+ }
54
+ /** Chrome rendered before the docs layout, so it comes first in focus order. */
55
+ function renderLayoutChrome(config, options) {
56
+ const chrome = [];
57
+ if (config.theme?.ui?.layout?.skipLink === true) chrome.push(/* @__PURE__ */ jsx("a", {
58
+ className: "fd-skip-link",
59
+ href: "#nd-page",
60
+ children: "Skip to content"
61
+ }, "fd-skip-link"));
62
+ if (isTopHeader(config)) chrome.push(/* @__PURE__ */ jsx(DocsTopHeader, {
63
+ title: options.navTitle,
64
+ titleUrl: options.navUrl,
65
+ links: resolveNavLinks(config),
66
+ search: options.search,
67
+ askAI: options.askAI,
68
+ themeToggle: options.themeToggle,
69
+ themeName: config.theme?.name,
70
+ height: topHeaderHeight(config)
71
+ }, "fd-top-header"));
72
+ return chrome.length > 0 ? chrome : null;
73
+ }
74
+
75
+ //#endregion
76
+ export { renderLayoutChrome, resolveLayoutContainerProps, resolveSidebarNavLinks, resolveSidebarNavTitle };