@windrun-huaiin/third-ui 31.2.0 → 31.3.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.
@@ -5,7 +5,6 @@ interface FumaPageParams {
5
5
  sourceKey: string;
6
6
  mdxContentSource: any | (() => Promise<any>);
7
7
  getMDXComponents: () => any;
8
- mdxSourceDir: string;
9
8
  githubBaseUrl?: string;
10
9
  copyButtonComponent?: ReactElement<LLMCopyButtonProps, typeof LLMCopyButton>;
11
10
  supportedLocales?: string[];
@@ -16,7 +15,7 @@ interface FumaPageParams {
16
15
  localePrefixAsNeeded?: boolean;
17
16
  defaultLocale?: string;
18
17
  }
19
- export declare function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, supportedLocales, showBreadcrumb, showTableOfContent, tocRenderMode, showTableOfContentPopover, localePrefixAsNeeded, defaultLocale, }: FumaPageParams): {
18
+ export declare function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, githubBaseUrl, copyButtonComponent, supportedLocales, showBreadcrumb, showTableOfContent, tocRenderMode, showTableOfContentPopover, localePrefixAsNeeded, defaultLocale, }: FumaPageParams): {
20
19
  Page: ({ params }: {
21
20
  params: Promise<{
22
21
  locale: string;
@@ -10,8 +10,9 @@ var navigation = require('next/navigation');
10
10
  var tocClerkPortable = require('./mdx/toc-clerk-portable.js');
11
11
  var lib = require('@windrun-huaiin/base-ui/lib');
12
12
 
13
- function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, tocRenderMode = 'portable-clerk', showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
13
+ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, githubBaseUrl, copyButtonComponent, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, tocRenderMode = 'portable-clerk', showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
14
14
  var _a;
15
+ const resolvedMdxSourceDir = `src/mdx/${sourceKey}`;
15
16
  const isLocalMdDebugEnabled = ((_a = process.env.LOCAL_MD_DEBUG) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'true';
16
17
  const now = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
17
18
  const durationMs = (startedAt) => Number((now() - startedAt).toFixed(1));
@@ -52,7 +53,7 @@ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSour
52
53
  if (!page$1) {
53
54
  navigation.notFound();
54
55
  }
55
- const path = githubBaseUrl ? `${mdxSourceDir}/${page$1.path}` : undefined;
56
+ const path = githubBaseUrl ? `${resolvedMdxSourceDir}/${page$1.path}` : undefined;
56
57
  const tocFooterElement = (jsxRuntime.jsx(tocFooterWrapper.TocFooterWrapper, { lastModified: page$1.data.date, copyButtonComponent: copyButtonComponent
57
58
  ? React.cloneElement(copyButtonComponent, { sourceKey })
58
59
  : undefined, editPath: path, githubBaseUrl: githubBaseUrl }));
@@ -118,7 +119,7 @@ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSour
118
119
  };
119
120
  }
120
121
  const baseUrl = process.env.NEXT_PUBLIC_BASE_URL;
121
- const baseRoute = mdxSourceDir.replace('src/mdx/', '');
122
+ const baseRoute = resolvedMdxSourceDir.replace('src/mdx/', '');
122
123
  // build the current page path
123
124
  const currentPath = slug ? slug.join('/') : '';
124
125
  const localizedPath = utils.getAsNeededLocalizedUrl(locale || defaultLocale, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`, localePrefixAsNeeded, defaultLocale);
@@ -8,8 +8,9 @@ import { notFound } from 'next/navigation';
8
8
  import { PortableClerkTOC, PortableClerkTOCTitle } from './mdx/toc-clerk-portable.mjs';
9
9
  import { themeSvgIconColor } from '@windrun-huaiin/base-ui/lib';
10
10
 
11
- function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, tocRenderMode = 'portable-clerk', showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
11
+ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, githubBaseUrl, copyButtonComponent, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, tocRenderMode = 'portable-clerk', showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
12
12
  var _a;
13
+ const resolvedMdxSourceDir = `src/mdx/${sourceKey}`;
13
14
  const isLocalMdDebugEnabled = ((_a = process.env.LOCAL_MD_DEBUG) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'true';
14
15
  const now = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
15
16
  const durationMs = (startedAt) => Number((now() - startedAt).toFixed(1));
@@ -50,7 +51,7 @@ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSour
50
51
  if (!page) {
51
52
  notFound();
52
53
  }
53
- const path = githubBaseUrl ? `${mdxSourceDir}/${page.path}` : undefined;
54
+ const path = githubBaseUrl ? `${resolvedMdxSourceDir}/${page.path}` : undefined;
54
55
  const tocFooterElement = (jsx(TocFooterWrapper, { lastModified: page.data.date, copyButtonComponent: copyButtonComponent
55
56
  ? cloneElement(copyButtonComponent, { sourceKey })
56
57
  : undefined, editPath: path, githubBaseUrl: githubBaseUrl }));
@@ -116,7 +117,7 @@ function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSour
116
117
  };
117
118
  }
118
119
  const baseUrl = process.env.NEXT_PUBLIC_BASE_URL;
119
- const baseRoute = mdxSourceDir.replace('src/mdx/', '');
120
+ const baseRoute = resolvedMdxSourceDir.replace('src/mdx/', '');
120
121
  // build the current page path
121
122
  const currentPath = slug ? slug.join('/') : '';
122
123
  const localizedPath = getAsNeededLocalizedUrl(locale || defaultLocale, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`, localePrefixAsNeeded, defaultLocale);
@@ -4,9 +4,12 @@
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var tocBase = require('./toc-base.js');
6
6
 
7
+ function joinUrlPath(baseUrl, path) {
8
+ return `${baseUrl.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
9
+ }
7
10
  function TocFooterWrapper({ lastModified, editPath, githubBaseUrl, copyButtonComponent }) {
8
11
  const showEdit = githubBaseUrl && editPath;
9
- return (jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-2 items-start m-4", children: [jsxRuntime.jsx(tocBase.LastUpdatedDate, { date: lastModified }), copyButtonComponent, showEdit && jsxRuntime.jsx(tocBase.EditOnGitHub, { url: `${githubBaseUrl}${editPath}` })] }));
12
+ return (jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-2 items-start m-4", children: [jsxRuntime.jsx(tocBase.LastUpdatedDate, { date: lastModified }), copyButtonComponent, showEdit && jsxRuntime.jsx(tocBase.EditOnGitHub, { url: joinUrlPath(githubBaseUrl, editPath) })] }));
10
13
  }
11
14
 
12
15
  exports.TocFooterWrapper = TocFooterWrapper;
@@ -2,9 +2,12 @@
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { LastUpdatedDate, EditOnGitHub } from './toc-base.mjs';
4
4
 
5
+ function joinUrlPath(baseUrl, path) {
6
+ return `${baseUrl.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
7
+ }
5
8
  function TocFooterWrapper({ lastModified, editPath, githubBaseUrl, copyButtonComponent }) {
6
9
  const showEdit = githubBaseUrl && editPath;
7
- return (jsxs("div", { className: "flex flex-col gap-y-2 items-start m-4", children: [jsx(LastUpdatedDate, { date: lastModified }), copyButtonComponent, showEdit && jsx(EditOnGitHub, { url: `${githubBaseUrl}${editPath}` })] }));
10
+ return (jsxs("div", { className: "flex flex-col gap-y-2 items-start m-4", children: [jsx(LastUpdatedDate, { date: lastModified }), copyButtonComponent, showEdit && jsx(EditOnGitHub, { url: joinUrlPath(githubBaseUrl, editPath) })] }));
8
11
  }
9
12
 
10
13
  export { TocFooterWrapper };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/third-ui",
3
- "version": "31.2.0",
3
+ "version": "31.3.1",
4
4
  "description": "Third-party integrated UI components for windrun-huaiin projects",
5
5
  "exports": {
6
6
  "./clerk": {
@@ -243,9 +243,9 @@
243
243
  "tslib": "^2.8.1",
244
244
  "unified": "^11.0.5",
245
245
  "zod": "^4.3.6",
246
- "@windrun-huaiin/lib": "^31.0.1",
246
+ "@windrun-huaiin/contracts": "^31.0.0",
247
247
  "@windrun-huaiin/base-ui": "^31.0.0",
248
- "@windrun-huaiin/contracts": "^31.0.0"
248
+ "@windrun-huaiin/lib": "^31.0.2"
249
249
  },
250
250
  "peerDependencies": {
251
251
  "clsx": "^2.1.1",
@@ -25,10 +25,6 @@ interface FumaPageParams {
25
25
  * The mdx components handler, refer to fumadocs
26
26
  */
27
27
  getMDXComponents: () => any;
28
- /*
29
- * The source directory of the mdx content, used to generate the edit path
30
- */
31
- mdxSourceDir: string;
32
28
  /*
33
29
  * The github base url, used to generate the edit path, if not provided, the edit path will not be shown
34
30
  */
@@ -79,7 +75,6 @@ export function createFumaPage({
79
75
  sourceKey,
80
76
  mdxContentSource,
81
77
  getMDXComponents,
82
- mdxSourceDir,
83
78
  githubBaseUrl,
84
79
  copyButtonComponent,
85
80
  supportedLocales = ['en'],
@@ -90,6 +85,7 @@ export function createFumaPage({
90
85
  localePrefixAsNeeded = true,
91
86
  defaultLocale = 'en',
92
87
  }: FumaPageParams) {
88
+ const resolvedMdxSourceDir = `src/mdx/${sourceKey}`;
93
89
  const isLocalMdDebugEnabled = process.env.LOCAL_MD_DEBUG?.toLowerCase() === 'true';
94
90
  const now = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
95
91
  const durationMs = (startedAt: number) => Number((now() - startedAt).toFixed(1));
@@ -132,7 +128,7 @@ export function createFumaPage({
132
128
  notFound();
133
129
  }
134
130
 
135
- const path = githubBaseUrl ? `${mdxSourceDir}/${page.path}` : undefined;
131
+ const path = githubBaseUrl ? `${resolvedMdxSourceDir}/${page.path}` : undefined;
136
132
  const tocFooterElement = (
137
133
  <TocFooterWrapper
138
134
  lastModified={page.data.date}
@@ -222,7 +218,7 @@ export function createFumaPage({
222
218
  };
223
219
  }
224
220
  const baseUrl = process.env.NEXT_PUBLIC_BASE_URL!;
225
- const baseRoute = mdxSourceDir.replace('src/mdx/', '');
221
+ const baseRoute = resolvedMdxSourceDir.replace('src/mdx/', '');
226
222
  // build the current page path
227
223
  const currentPath = slug ? slug.join('/') : '';
228
224
  const localizedPath = getAsNeededLocalizedUrl(locale || defaultLocale, `/${baseRoute}${currentPath ? `/${currentPath}` : ''}`, localePrefixAsNeeded, defaultLocale);
@@ -10,13 +10,17 @@ interface TocFooterProps {
10
10
  copyButtonComponent?: React.ReactNode;
11
11
  }
12
12
 
13
+ function joinUrlPath(baseUrl: string, path: string) {
14
+ return `${baseUrl.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
15
+ }
16
+
13
17
  export function TocFooterWrapper({ lastModified, editPath, githubBaseUrl, copyButtonComponent }: TocFooterProps) {
14
18
  const showEdit = githubBaseUrl && editPath;
15
19
  return (
16
20
  <div className="flex flex-col gap-y-2 items-start m-4">
17
21
  <LastUpdatedDate date={lastModified} />
18
22
  {copyButtonComponent}
19
- {showEdit && <EditOnGitHub url={`${githubBaseUrl}${editPath}`} />}
23
+ {showEdit && <EditOnGitHub url={joinUrlPath(githubBaseUrl, editPath)} />}
20
24
  </div>
21
25
  );
22
26
  }