@windrun-huaiin/third-ui 5.7.0 → 5.8.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.
@@ -0,0 +1,15 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface LLMCopyButtonProps {
4
+ llmApiUrl?: string;
5
+ sourceKey?: string;
6
+ }
7
+ declare function LLMCopyButton({ llmApiUrl, sourceKey }?: LLMCopyButtonProps): react_jsx_runtime.JSX.Element;
8
+ declare function EditOnGitHub({ url }: {
9
+ url: string;
10
+ }): react_jsx_runtime.JSX.Element;
11
+ declare function LastUpdatedDate({ date }: {
12
+ date: string | undefined;
13
+ }): react_jsx_runtime.JSX.Element;
14
+
15
+ export { EditOnGitHub as E, type LLMCopyButtonProps as L, LLMCopyButton as a, LastUpdatedDate as b };
@@ -0,0 +1,15 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface LLMCopyButtonProps {
4
+ llmApiUrl?: string;
5
+ sourceKey?: string;
6
+ }
7
+ declare function LLMCopyButton({ llmApiUrl, sourceKey }?: LLMCopyButtonProps): react_jsx_runtime.JSX.Element;
8
+ declare function EditOnGitHub({ url }: {
9
+ url: string;
10
+ }): react_jsx_runtime.JSX.Element;
11
+ declare function LastUpdatedDate({ date }: {
12
+ date: string | undefined;
13
+ }): react_jsx_runtime.JSX.Element;
14
+
15
+ export { EditOnGitHub as E, type LLMCopyButtonProps as L, LLMCopyButton as a, LastUpdatedDate as b };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/third-ui",
3
- "version": "5.7.0",
3
+ "version": "5.8.0",
4
4
  "description": "Third-party integrated UI components for windrun-huaiin projects",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,8 +1,13 @@
1
1
  import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/page';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, ReactElement, cloneElement } from 'react';
3
3
  import { TocFooterWrapper } from '@third-ui/fuma/mdx';
4
+ import type { LLMCopyButtonProps, LLMCopyButton } from '@third-ui/fuma/mdx';
4
5
 
5
- interface FumaPageParams {
6
+ interface FumaPageParams {
7
+ /*
8
+ * The source key of the mdx content, used to generate the edit path
9
+ */
10
+ sourceKey: string;
6
11
  /*
7
12
  * The source of the mdx content
8
13
  */
@@ -20,9 +25,9 @@ interface FumaPageParams {
20
25
  */
21
26
  githubBaseUrl?: string;
22
27
  /*
23
- * The copy button component, if provided, will be rendered in the footer (should be a client component)
28
+ * The copy button component, must be LLMCopyButton
24
29
  */
25
- copyButtonComponent?: ReactNode;
30
+ copyButtonComponent?: ReactElement<LLMCopyButtonProps, typeof LLMCopyButton>;
26
31
  /*
27
32
  * The site icon component to use in NotFoundPage
28
33
  */
@@ -34,6 +39,7 @@ interface FumaPageParams {
34
39
  }
35
40
 
36
41
  export function createFumaPage({
42
+ sourceKey,
37
43
  mdxContentSource,
38
44
  getMDXComponents,
39
45
  mdxSourceDir,
@@ -53,7 +59,11 @@ export function createFumaPage({
53
59
  const tocFooterElement = (
54
60
  <TocFooterWrapper
55
61
  lastModified={page.data.date}
56
- copyButtonComponent={copyButtonComponent}
62
+ copyButtonComponent={
63
+ copyButtonComponent
64
+ ? cloneElement(copyButtonComponent, { sourceKey })
65
+ : undefined
66
+ }
57
67
  editPath={path}
58
68
  githubBaseUrl={githubBaseUrl}
59
69
  />
@@ -9,7 +9,12 @@ import { Button } from '@base-ui/ui/button';
9
9
 
10
10
  const cache = new Map<string, string>();
11
11
 
12
- export function LLMCopyButton({ llmApiUrl }: { llmApiUrl?: string } = {}) {
12
+ export interface LLMCopyButtonProps {
13
+ llmApiUrl?: string;
14
+ sourceKey?: string;
15
+ }
16
+
17
+ export function LLMCopyButton({ llmApiUrl, sourceKey }: LLMCopyButtonProps = {}) {
13
18
  const [isLoading, setLoading] = useState(false);
14
19
  const params = useParams();
15
20
  const locale = params.locale as string;
@@ -21,7 +26,10 @@ export function LLMCopyButton({ llmApiUrl }: { llmApiUrl?: string } = {}) {
21
26
  // Handle cases where slug might be undefined or empty
22
27
  const path = (slug && Array.isArray(slug)) ? slug.join('/') : '';
23
28
  const apiPrefix = llmApiUrl || '/api/llm-content';
24
- const apiUrl = `${apiPrefix}?locale=${encodeURIComponent(locale)}&path=${encodeURIComponent(path)}`;
29
+ let apiUrl = `${apiPrefix}?locale=${encodeURIComponent(locale)}&path=${encodeURIComponent(path)}`;
30
+ if (sourceKey) {
31
+ apiUrl += `&sourceKey=${encodeURIComponent(sourceKey)}`;
32
+ }
25
33
  console.log('Fetching LLM content from:', apiUrl);
26
34
 
27
35
  let content: string;