@farming-labs/theme 0.0.2-beta.27 → 0.0.2-beta.29

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.
@@ -53,15 +53,15 @@ function PathBreadcrumb({ pathname, entry }) {
53
53
  * (Copy Markdown, Open in LLM). Re-scans when the route changes.
54
54
  */
55
55
  /**
56
- * Build the GitHub URL for the current page's source file.
56
+ * Build the GitHub URL for the current page's source file (edit view).
57
57
  *
58
58
  * Examples:
59
- * No directory: https://github.com/user/repo/tree/main/app/docs/cli/page.mdx
60
- * With directory: https://github.com/farming-labs/docs/tree/main/website/app/docs/cli/page.mdx
59
+ * No directory: https://github.com/user/repo/edit/main/app/docs/cli/page.mdx
60
+ * With directory: https://github.com/farming-labs/docs/edit/main/website/app/docs/cli/page.mdx
61
61
  */
62
62
  function buildGithubFileUrl(githubUrl, branch, pathname, directory) {
63
63
  const segments = pathname.replace(/^\//, "").replace(/\/$/, "");
64
- return `${githubUrl}/tree/${branch}/${directory ? `${directory}/` : ""}app/${segments}/page.mdx`;
64
+ return `${githubUrl}/edit/${branch}/${`${directory ? `${directory}/` : ""}app/${segments}/page.mdx`}`;
65
65
  }
66
66
  function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled = true, entry = "docs", copyMarkdown = false, openDocs = false, openDocsProviders, pageActionsPosition = "below-title", pageActionsAlignment = "left", githubUrl, githubBranch = "main", githubDirectory, lastModifiedMap, lastUpdatedEnabled = true, lastUpdatedPosition = "footer", llmsTxtEnabled = false, descriptionMap, description, children }) {
67
67
  const fdTocStyle = tocStyle === "directional" ? "clerk" : void 0;
@@ -176,7 +176,8 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
176
176
  showActions && actionsPortalTarget && createPortal(/* @__PURE__ */ jsx(PageActions, {
177
177
  copyMarkdown,
178
178
  openDocs,
179
- providers: openDocsProviders
179
+ providers: openDocsProviders,
180
+ githubFileUrl
180
181
  }), actionsPortalTarget),
181
182
  /* @__PURE__ */ jsxs(DocsBody, {
182
183
  style: {
@@ -11,11 +11,14 @@ interface PageActionsProps {
11
11
  copyMarkdown?: boolean;
12
12
  openDocs?: boolean;
13
13
  providers?: SerializedProvider[];
14
+ /** GitHub file URL (edit view) for the current page. Used when urlTemplate contains {githubUrl}. */
15
+ githubFileUrl?: string | null;
14
16
  }
15
17
  declare function PageActions({
16
18
  copyMarkdown,
17
19
  openDocs,
18
- providers
20
+ providers,
21
+ githubFileUrl
19
22
  }: PageActionsProps): react_jsx_runtime0.JSX.Element | null;
20
23
  //#endregion
21
24
  export { PageActions };
@@ -72,7 +72,7 @@ const DEFAULT_PROVIDERS = [{
72
72
  name: "Claude",
73
73
  urlTemplate: "https://claude.ai/new?q=Read+{mdxUrl},+I+want+to+ask+questions+about+it."
74
74
  }];
75
- function PageActions({ copyMarkdown, openDocs, providers }) {
75
+ function PageActions({ copyMarkdown, openDocs, providers, githubFileUrl }) {
76
76
  const [copied, setCopied] = useState(false);
77
77
  const [dropdownOpen, setDropdownOpen] = useState(false);
78
78
  const dropdownRef = useRef(null);
@@ -89,12 +89,16 @@ function PageActions({ copyMarkdown, openDocs, providers }) {
89
89
  } catch {}
90
90
  }, []);
91
91
  const handleOpen = useCallback((template) => {
92
+ if (/\{githubUrl\}/.test(template) && !githubFileUrl) {
93
+ setDropdownOpen(false);
94
+ return;
95
+ }
92
96
  const pageUrl = window.location.href;
93
97
  const mdxUrl = `${window.location.origin}${pathname}.mdx`;
94
- const url = template.replace(/\{url\}/g, encodeURIComponent(pageUrl)).replace(/\{mdxUrl\}/g, encodeURIComponent(mdxUrl));
98
+ let url = template.replace(/\{url\}/g, encodeURIComponent(pageUrl)).replace(/\{mdxUrl\}/g, encodeURIComponent(mdxUrl)).replace(/\{githubUrl\}/g, githubFileUrl ?? "");
95
99
  window.open(url, "_blank", "noopener,noreferrer");
96
100
  setDropdownOpen(false);
97
- }, [pathname]);
101
+ }, [pathname, githubFileUrl]);
98
102
  useEffect(() => {
99
103
  if (!dropdownOpen) return;
100
104
  function handleClick(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.0.2-beta.27",
3
+ "version": "0.0.2-beta.29",
4
4
  "description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
5
5
  "keywords": [
6
6
  "docs",
@@ -98,7 +98,7 @@
98
98
  "next": ">=14.0.0",
99
99
  "tsdown": "^0.20.3",
100
100
  "typescript": "^5.9.3",
101
- "@farming-labs/docs": "0.0.2-beta.27"
101
+ "@farming-labs/docs": "0.0.2-beta.29"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "@farming-labs/docs": ">=0.0.1",