@windrun-huaiin/third-ui 22.0.0 → 23.0.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.
Files changed (67) hide show
  1. package/README.md +6 -6
  2. package/dist/fuma/server/features/base.d.ts +2 -0
  3. package/dist/fuma/server/features/base.js +13 -0
  4. package/dist/fuma/server/features/base.mjs +11 -0
  5. package/dist/fuma/server/features/code.d.ts +3 -0
  6. package/dist/fuma/server/features/code.js +66 -0
  7. package/dist/fuma/server/features/code.mjs +64 -0
  8. package/dist/fuma/server/features/math.d.ts +2 -0
  9. package/dist/fuma/server/features/math.js +14 -0
  10. package/dist/fuma/server/features/math.mjs +12 -0
  11. package/dist/fuma/server/features/mermaid.d.ts +2 -0
  12. package/dist/fuma/server/features/mermaid.js +13 -0
  13. package/dist/fuma/server/features/mermaid.mjs +11 -0
  14. package/dist/fuma/server/features/type-table.d.ts +2 -0
  15. package/dist/fuma/server/features/type-table.js +12 -0
  16. package/dist/fuma/server/features/type-table.mjs +10 -0
  17. package/dist/fuma/server/features/widgets.d.ts +2 -0
  18. package/dist/fuma/server/features/widgets.js +26 -0
  19. package/dist/fuma/server/features/widgets.mjs +24 -0
  20. package/dist/fuma/server/optional-features.d.ts +6 -8
  21. package/dist/fuma/server/optional-features.js +13 -107
  22. package/dist/fuma/server/optional-features.mjs +6 -104
  23. package/dist/fuma/server/site-mdx-base.d.ts +13 -0
  24. package/dist/fuma/server/site-mdx-base.js +32 -0
  25. package/dist/fuma/server/site-mdx-base.mjs +29 -0
  26. package/dist/fuma/server/site-mdx-components.d.ts +1 -1
  27. package/dist/fuma/server/site-mdx-components.js +7 -8
  28. package/dist/fuma/server/site-mdx-components.mjs +8 -9
  29. package/dist/fuma/server/site-mdx-fallbacks.d.ts +18 -0
  30. package/dist/fuma/server/site-mdx-fallbacks.js +49 -0
  31. package/dist/fuma/server/site-mdx-fallbacks.mjs +45 -0
  32. package/dist/fuma/server/site-mdx-features/code.d.ts +1 -0
  33. package/dist/fuma/server/site-mdx-features/code.js +7 -0
  34. package/dist/fuma/server/site-mdx-features/code.mjs +1 -0
  35. package/dist/fuma/server/site-mdx-features/math.d.ts +1 -0
  36. package/dist/fuma/server/site-mdx-features/math.js +7 -0
  37. package/dist/fuma/server/site-mdx-features/math.mjs +1 -0
  38. package/dist/fuma/server/site-mdx-features/mermaid.d.ts +1 -0
  39. package/dist/fuma/server/site-mdx-features/mermaid.js +7 -0
  40. package/dist/fuma/server/site-mdx-features/mermaid.mjs +1 -0
  41. package/dist/fuma/server/site-mdx-features/type-table.d.ts +1 -0
  42. package/dist/fuma/server/site-mdx-features/type-table.js +7 -0
  43. package/dist/fuma/server/site-mdx-features/type-table.mjs +1 -0
  44. package/dist/fuma/server/site-mdx-presets.d.ts +2 -1
  45. package/dist/fuma/server/site-mdx-presets.js +22 -13
  46. package/dist/fuma/server/site-mdx-presets.mjs +22 -12
  47. package/dist/fuma/share/markdown-component-map.js +43 -29
  48. package/dist/fuma/share/markdown-component-map.mjs +42 -28
  49. package/dist/lib/seo-metadata.js +34 -0
  50. package/dist/lib/seo-metadata.mjs +32 -0
  51. package/package.json +29 -7
  52. package/src/fuma/server/features/base.tsx +23 -0
  53. package/src/fuma/server/features/code.tsx +104 -0
  54. package/src/fuma/server/features/math.ts +16 -0
  55. package/src/fuma/server/features/mermaid.tsx +21 -0
  56. package/src/fuma/server/features/type-table.ts +12 -0
  57. package/src/fuma/server/features/widgets.tsx +34 -0
  58. package/src/fuma/server/optional-features.tsx +6 -168
  59. package/src/fuma/server/site-mdx-base.tsx +62 -0
  60. package/src/fuma/server/site-mdx-components.tsx +10 -12
  61. package/src/fuma/server/site-mdx-fallbacks.tsx +122 -0
  62. package/src/fuma/server/site-mdx-features/code.ts +1 -0
  63. package/src/fuma/server/site-mdx-features/math.ts +1 -0
  64. package/src/fuma/server/site-mdx-features/mermaid.ts +1 -0
  65. package/src/fuma/server/site-mdx-features/type-table.ts +1 -0
  66. package/src/fuma/server/site-mdx-presets.ts +52 -1
  67. package/src/fuma/share/markdown-component-map.tsx +5 -4
@@ -1,77 +1,91 @@
1
1
  import { __rest } from 'tslib';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { cn } from '@windrun-huaiin/lib/utils';
4
- import defaultMdxComponents from 'fumadocs-ui/mdx';
5
- import { ImageZoom } from '../heavy/image-zoom.mjs';
6
- import 'katex';
7
- import '@windrun-huaiin/base-ui/icons';
8
- import 'next-themes';
9
- import 'roughjs';
10
- import 'react';
11
- import '@windrun-huaiin/base-ui/lib';
4
+ import { lazy } from 'react';
12
5
 
6
+ const ImageZoom = lazy(() => import('../heavy/image-zoom.mjs').then((mod) => ({ default: mod.ImageZoom })));
13
7
  function normalizeMarkdownProps(props) {
14
8
  const { class: legacyClassName, className } = props, restProps = __rest(props, ["class", "className"]);
15
9
  return Object.assign(Object.assign({}, restProps), { className: cn(typeof legacyClassName === 'string' ? legacyClassName : undefined, className) });
16
10
  }
17
- const baseMarkdownComponents = Object.assign(Object.assign({}, defaultMdxComponents), { a: (_a) => {
11
+ const baseMarkdownComponents = {
12
+ a: (_a) => {
18
13
  var _b, _c;
19
14
  var { className } = _a, props = __rest(_a, ["className"]);
20
15
  return (jsx("a", Object.assign({}, normalizeMarkdownProps(props), { className: cn('underline underline-offset-4 transition hover:opacity-80', normalizeMarkdownProps(props).className, className), target: (_b = props.target) !== null && _b !== void 0 ? _b : '_blank', rel: (_c = props.rel) !== null && _c !== void 0 ? _c : 'noreferrer noopener' })));
21
- }, blockquote: (_a) => {
16
+ },
17
+ blockquote: (_a) => {
22
18
  var { className } = _a, props = __rest(_a, ["className"]);
23
19
  return (jsx("blockquote", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border-l-2 border-border pl-4 text-muted-foreground', normalizeMarkdownProps(props).className, className) })));
24
- }, code: (_a) => {
20
+ },
21
+ code: (_a) => {
25
22
  var { className } = _a, props = __rest(_a, ["className"]);
26
23
  return (jsx("code", Object.assign({}, normalizeMarkdownProps(props), { className: cn('rounded-md bg-muted px-1.5 py-0.5 font-mono text-[0.9em]', normalizeMarkdownProps(props).className, className) })));
27
- }, h1: (_a) => {
24
+ },
25
+ h1: (_a) => {
28
26
  var { className } = _a, props = __rest(_a, ["className"]);
29
27
  return (jsx("h1", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-2xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
30
- }, h2: (_a) => {
28
+ },
29
+ h2: (_a) => {
31
30
  var { className } = _a, props = __rest(_a, ["className"]);
32
31
  return (jsx("h2", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
33
- }, h3: (_a) => {
32
+ },
33
+ h3: (_a) => {
34
34
  var { className } = _a, props = __rest(_a, ["className"]);
35
35
  return (jsx("h3", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-lg font-semibold', normalizeMarkdownProps(props).className, className) })));
36
- }, h4: (_a) => {
36
+ },
37
+ h4: (_a) => {
37
38
  var { className } = _a, props = __rest(_a, ["className"]);
38
39
  return (jsx("h4", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-base font-semibold', normalizeMarkdownProps(props).className, className) })));
39
- }, h5: (_a) => {
40
+ },
41
+ h5: (_a) => {
40
42
  var { className } = _a, props = __rest(_a, ["className"]);
41
43
  return (jsx("h5", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
42
- }, h6: (_a) => {
44
+ },
45
+ h6: (_a) => {
43
46
  var { className } = _a, props = __rest(_a, ["className"]);
44
47
  return (jsx("h6", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
45
- }, hr: (_a) => {
48
+ },
49
+ hr: (_a) => {
46
50
  var { className } = _a, props = __rest(_a, ["className"]);
47
51
  return (jsx("hr", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border-border', normalizeMarkdownProps(props).className, className) })));
48
- }, img: (_a) => {
52
+ },
53
+ img: (_a) => {
49
54
  var { className, alt, src } = _a, props = __rest(_a, ["className", "alt", "src"]);
50
55
  return (jsx(ImageZoom, Object.assign({}, normalizeMarkdownProps(props), { alt: typeof alt === 'string' ? alt : '', src: typeof src === 'string' ? src : '', className: cn('overflow-hidden rounded-2xl', normalizeMarkdownProps(props).className, className) })));
51
- }, li: (_a) => {
56
+ },
57
+ li: (_a) => {
52
58
  var { className } = _a, props = __rest(_a, ["className"]);
53
59
  return (jsx("li", Object.assign({}, normalizeMarkdownProps(props), { className: cn('leading-7', normalizeMarkdownProps(props).className, className) })));
54
- }, ol: (_a) => {
60
+ },
61
+ ol: (_a) => {
55
62
  var { className } = _a, props = __rest(_a, ["className"]);
56
63
  return (jsx("ol", Object.assign({}, normalizeMarkdownProps(props), { className: cn('list-decimal space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
57
- }, p: (_a) => {
64
+ },
65
+ p: (_a) => {
58
66
  var { className } = _a, props = __rest(_a, ["className"]);
59
67
  return (jsx("p", Object.assign({}, normalizeMarkdownProps(props), { className: cn('leading-7', normalizeMarkdownProps(props).className, className) })));
60
- }, pre: (_a) => {
68
+ },
69
+ pre: (_a) => {
61
70
  var { className } = _a, props = __rest(_a, ["className"]);
62
71
  return (jsx("pre", Object.assign({}, normalizeMarkdownProps(props), { className: cn('overflow-x-auto rounded-2xl border border-border bg-muted px-4 py-3 text-sm', normalizeMarkdownProps(props).className, className) })));
63
- }, table: (_a) => {
72
+ },
73
+ table: (_a) => {
64
74
  var { className } = _a, props = __rest(_a, ["className"]);
65
75
  return (jsx("div", { className: "overflow-x-auto", children: jsx("table", Object.assign({}, normalizeMarkdownProps(props), { className: cn('w-full border-collapse text-sm', normalizeMarkdownProps(props).className, className) })) }));
66
- }, td: (_a) => {
76
+ },
77
+ td: (_a) => {
67
78
  var { className } = _a, props = __rest(_a, ["className"]);
68
79
  return (jsx("td", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border border-border px-3 py-2 align-top', normalizeMarkdownProps(props).className, className) })));
69
- }, th: (_a) => {
80
+ },
81
+ th: (_a) => {
70
82
  var { className } = _a, props = __rest(_a, ["className"]);
71
83
  return (jsx("th", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border border-border px-3 py-2 text-left font-medium', normalizeMarkdownProps(props).className, className) })));
72
- }, ul: (_a) => {
84
+ },
85
+ ul: (_a) => {
73
86
  var { className } = _a, props = __rest(_a, ["className"]);
74
87
  return (jsx("ul", Object.assign({}, normalizeMarkdownProps(props), { className: cn('list-disc space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
75
- } });
88
+ },
89
+ };
76
90
 
77
91
  export { baseMarkdownComponents };
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var server = require('next-intl/server');
5
+ var lib = require('@windrun-huaiin/lib');
6
+
7
+ const DEFAULT_SITE_ICONS = [
8
+ { rel: 'icon', type: 'image/png', sizes: '16x16', url: '/favicon-16x16.png' },
9
+ { rel: 'icon', type: 'image/png', sizes: '32x32', url: '/favicon-32x32.png' },
10
+ { rel: 'icon', type: 'image/ico', url: '/favicon.ico' },
11
+ { rel: 'apple-touch-icon', sizes: '180x180', url: '/favicon-180x180.png' },
12
+ { rel: 'android-chrome', sizes: '512x512', url: '/favicon-512x512.png' },
13
+ ];
14
+ function createLocalizedSiteMetadata(options) {
15
+ return tslib.__awaiter(this, void 0, void 0, function* () {
16
+ const { baseUrl, defaultLocale, locale, localePrefixAsNeeded, locales } = options;
17
+ const t = yield server.getTranslations({ locale, namespace: 'home' });
18
+ return {
19
+ title: t('webTitle'),
20
+ description: t('webDescription'),
21
+ keywords: t('keywords'),
22
+ alternates: {
23
+ canonical: `${baseUrl}${lib.getAsNeededLocalizedUrl(locale, '/', localePrefixAsNeeded, defaultLocale)}`,
24
+ languages: Object.fromEntries(locales.map((siteLocale) => [
25
+ siteLocale,
26
+ `${baseUrl}${lib.getAsNeededLocalizedUrl(siteLocale, '/', localePrefixAsNeeded, defaultLocale)}`,
27
+ ])),
28
+ },
29
+ icons: DEFAULT_SITE_ICONS,
30
+ };
31
+ });
32
+ }
33
+
34
+ exports.createLocalizedSiteMetadata = createLocalizedSiteMetadata;
@@ -0,0 +1,32 @@
1
+ import { __awaiter } from 'tslib';
2
+ import { getTranslations } from 'next-intl/server';
3
+ import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib';
4
+
5
+ const DEFAULT_SITE_ICONS = [
6
+ { rel: 'icon', type: 'image/png', sizes: '16x16', url: '/favicon-16x16.png' },
7
+ { rel: 'icon', type: 'image/png', sizes: '32x32', url: '/favicon-32x32.png' },
8
+ { rel: 'icon', type: 'image/ico', url: '/favicon.ico' },
9
+ { rel: 'apple-touch-icon', sizes: '180x180', url: '/favicon-180x180.png' },
10
+ { rel: 'android-chrome', sizes: '512x512', url: '/favicon-512x512.png' },
11
+ ];
12
+ function createLocalizedSiteMetadata(options) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ const { baseUrl, defaultLocale, locale, localePrefixAsNeeded, locales } = options;
15
+ const t = yield getTranslations({ locale, namespace: 'home' });
16
+ return {
17
+ title: t('webTitle'),
18
+ description: t('webDescription'),
19
+ keywords: t('keywords'),
20
+ alternates: {
21
+ canonical: `${baseUrl}${getAsNeededLocalizedUrl(locale, '/', localePrefixAsNeeded, defaultLocale)}`,
22
+ languages: Object.fromEntries(locales.map((siteLocale) => [
23
+ siteLocale,
24
+ `${baseUrl}${getAsNeededLocalizedUrl(siteLocale, '/', localePrefixAsNeeded, defaultLocale)}`,
25
+ ])),
26
+ },
27
+ icons: DEFAULT_SITE_ICONS,
28
+ };
29
+ });
30
+ }
31
+
32
+ export { createLocalizedSiteMetadata };
package/package.json CHANGED
@@ -1,10 +1,7 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/third-ui",
3
- "version": "22.0.0",
3
+ "version": "23.0.0",
4
4
  "description": "Third-party integrated UI components for windrun-huaiin projects",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
5
  "exports": {
9
6
  "./clerk": {
10
7
  "types": "./dist/clerk/index.d.ts",
@@ -56,6 +53,31 @@
56
53
  "import": "./dist/fuma/server/site-mdx-components.mjs",
57
54
  "require": "./dist/fuma/server/site-mdx-components.js"
58
55
  },
56
+ "./fuma/server/site-mdx/base": {
57
+ "types": "./dist/fuma/server/site-mdx-base.d.ts",
58
+ "import": "./dist/fuma/server/site-mdx-base.mjs",
59
+ "require": "./dist/fuma/server/site-mdx-base.js"
60
+ },
61
+ "./fuma/server/site-mdx/features/code": {
62
+ "types": "./dist/fuma/server/site-mdx-features/code.d.ts",
63
+ "import": "./dist/fuma/server/site-mdx-features/code.mjs",
64
+ "require": "./dist/fuma/server/site-mdx-features/code.js"
65
+ },
66
+ "./fuma/server/site-mdx/features/math": {
67
+ "types": "./dist/fuma/server/site-mdx-features/math.d.ts",
68
+ "import": "./dist/fuma/server/site-mdx-features/math.mjs",
69
+ "require": "./dist/fuma/server/site-mdx-features/math.js"
70
+ },
71
+ "./fuma/server/site-mdx/features/mermaid": {
72
+ "types": "./dist/fuma/server/site-mdx-features/mermaid.d.ts",
73
+ "import": "./dist/fuma/server/site-mdx-features/mermaid.mjs",
74
+ "require": "./dist/fuma/server/site-mdx-features/mermaid.js"
75
+ },
76
+ "./fuma/server/site-mdx/features/type-table": {
77
+ "types": "./dist/fuma/server/site-mdx-features/type-table.d.ts",
78
+ "import": "./dist/fuma/server/site-mdx-features/type-table.mjs",
79
+ "require": "./dist/fuma/server/site-mdx-features/type-table.js"
80
+ },
59
81
  "./fuma/share": {
60
82
  "types": "./dist/fuma/share/index.d.ts",
61
83
  "import": "./dist/fuma/share/index.mjs",
@@ -125,9 +147,9 @@
125
147
  "tslib": "^2.8.1",
126
148
  "unified": "^11.0.5",
127
149
  "zod": "^4.3.6",
128
- "@windrun-huaiin/base-ui": "^22.0.0",
129
- "@windrun-huaiin/contracts": "^22.0.0",
130
- "@windrun-huaiin/lib": "^22.0.0"
150
+ "@windrun-huaiin/base-ui": "^23.0.0",
151
+ "@windrun-huaiin/lib": "^23.0.0",
152
+ "@windrun-huaiin/contracts": "^23.0.0"
131
153
  },
132
154
  "peerDependencies": {
133
155
  "clsx": "^2.1.1",
@@ -0,0 +1,23 @@
1
+ import type { MDXComponents } from 'mdx/types';
2
+ import { baseMarkdownComponents } from '../../share/markdown-component-map';
3
+ import { lazy } from 'react';
4
+ import { createMissingMdxFeatureComponents } from '../site-mdx-fallbacks';
5
+
6
+ const ImageZoom = lazy(() =>
7
+ import('../../heavy/image-zoom').then((mod) => ({ default: mod.ImageZoom })),
8
+ );
9
+
10
+ export function createBaseMdxComponents(
11
+ imageFallbackSrc?: string,
12
+ ): MDXComponents {
13
+ return {
14
+ ...baseMarkdownComponents,
15
+ ...createMissingMdxFeatureComponents(),
16
+ img: (props) => (
17
+ <ImageZoom
18
+ {...(props as any)}
19
+ fallbackSrc={imageFallbackSrc}
20
+ />
21
+ ),
22
+ };
23
+ }
@@ -0,0 +1,104 @@
1
+ import type { MDXComponents, MDXProps } from 'mdx/types';
2
+ import { lazy, type ReactNode } from 'react';
3
+ import {
4
+ CSSIcon,
5
+ CSVIcon,
6
+ DiffIcon,
7
+ HtmlIcon,
8
+ HttpIcon,
9
+ JavaIcon,
10
+ JsonIcon,
11
+ LogIcon,
12
+ MDXIcon,
13
+ RegexIcon,
14
+ SQLIcon,
15
+ SchemeIcon,
16
+ SquareDashedBottomCodeIcon,
17
+ TxtIcon,
18
+ XMLIcon,
19
+ YamlIcon,
20
+ } from '@windrun-huaiin/base-ui/icons';
21
+
22
+ const CodeBlock = lazy(() =>
23
+ import('fumadocs-ui/components/codeblock').then((mod) => ({ default: mod.CodeBlock })),
24
+ );
25
+ const Pre = lazy(() =>
26
+ import('fumadocs-ui/components/codeblock').then((mod) => ({ default: mod.Pre })),
27
+ );
28
+
29
+ const defaultCodeLanguageIconMap: Record<string, ReactNode> = {
30
+ css: <CSSIcon />,
31
+ csv: <CSVIcon />,
32
+ diff: <DiffIcon />,
33
+ html: <HtmlIcon />,
34
+ http: <HttpIcon />,
35
+ java: <JavaIcon />,
36
+ json: <JsonIcon />,
37
+ jsonc: <SquareDashedBottomCodeIcon />,
38
+ log: <LogIcon />,
39
+ mdx: <MDXIcon />,
40
+ plaintext: <TxtIcon />,
41
+ regex: <RegexIcon />,
42
+ scheme: <SchemeIcon />,
43
+ sql: <SQLIcon />,
44
+ text: <TxtIcon />,
45
+ txt: <TxtIcon />,
46
+ xml: <XMLIcon />,
47
+ yaml: <YamlIcon />,
48
+ yml: <YamlIcon />,
49
+ };
50
+
51
+ function tryToMatchIcon(
52
+ props: Readonly<MDXProps & { 'data-language'?: string; title?: string }>,
53
+ iconMap: Record<string, ReactNode>,
54
+ ): ReactNode | undefined {
55
+ let lang: string | undefined;
56
+
57
+ const dataLanguage = props['data-language'] as string | undefined;
58
+
59
+ if (dataLanguage && dataLanguage.trim() !== '') {
60
+ lang = dataLanguage.trim().toLowerCase();
61
+ } else {
62
+ const title = props.title as string | undefined;
63
+ if (title) {
64
+ const titleParts = title.split('.');
65
+ if (titleParts.length > 1 && titleParts[0] !== '') {
66
+ const extension = titleParts.pop()?.toLowerCase();
67
+ if (extension) {
68
+ lang = extension;
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ if (lang && iconMap[lang]) {
75
+ return iconMap[lang];
76
+ }
77
+
78
+ return undefined;
79
+ }
80
+
81
+ export function createCodeMdxComponents(
82
+ iconMap: Record<string, ReactNode> = {},
83
+ ): MDXComponents {
84
+ const mergedIconMap = {
85
+ ...defaultCodeLanguageIconMap,
86
+ ...iconMap,
87
+ };
88
+
89
+ return {
90
+ pre: (props) => {
91
+ const customIcon = tryToMatchIcon(props as MDXProps & { 'data-language'?: string; title?: string }, mergedIconMap);
92
+ return (
93
+ <CodeBlock
94
+ {...props}
95
+ {...(customIcon && { icon: customIcon })}
96
+ >
97
+ <Pre>{props.children}</Pre>
98
+ </CodeBlock>
99
+ );
100
+ },
101
+ CodeBlock,
102
+ Pre,
103
+ };
104
+ }
@@ -0,0 +1,16 @@
1
+ import type { MDXComponents } from 'mdx/types';
2
+ import { lazy } from 'react';
3
+
4
+ const MathBlock = lazy(() =>
5
+ import('../../heavy/math').then((mod) => ({ default: mod.MathBlock })),
6
+ );
7
+ const InlineMath = lazy(() =>
8
+ import('../../heavy/math').then((mod) => ({ default: mod.InlineMath })),
9
+ );
10
+
11
+ export function createMathMdxComponents(): MDXComponents {
12
+ return {
13
+ MathBlock,
14
+ InlineMath,
15
+ };
16
+ }
@@ -0,0 +1,21 @@
1
+ import type { MDXComponents } from 'mdx/types';
2
+ import { lazy } from 'react';
3
+
4
+ const Mermaid = lazy(() =>
5
+ import('../../heavy/mermaid').then((mod) => ({ default: mod.Mermaid })),
6
+ );
7
+
8
+ export function createMermaidMdxComponents(
9
+ watermarkEnabled?: boolean,
10
+ watermarkText?: string,
11
+ ): MDXComponents {
12
+ return {
13
+ Mermaid: (props) => (
14
+ <Mermaid
15
+ {...props}
16
+ watermarkEnabled={watermarkEnabled}
17
+ watermarkText={watermarkText}
18
+ />
19
+ ),
20
+ };
21
+ }
@@ -0,0 +1,12 @@
1
+ import type { MDXComponents } from 'mdx/types';
2
+ import { lazy } from 'react';
3
+
4
+ const TypeTable = lazy(() =>
5
+ import('fumadocs-ui/components/type-table').then((mod) => ({ default: mod.TypeTable })),
6
+ );
7
+
8
+ export function createTypeTableMdxComponents(): MDXComponents {
9
+ return {
10
+ TypeTable,
11
+ };
12
+ }
@@ -0,0 +1,34 @@
1
+ import type { MDXComponents } from 'mdx/types';
2
+ import { lazy } from 'react';
3
+ import { TrophyCard } from '../../mdx/trophy-card';
4
+ import { ZiaCard } from '../../mdx/zia-card';
5
+ import { GradientButton } from '../../mdx/gradient-button';
6
+ import { ZiaFile, ZiaFolder } from '../../mdx/zia-file';
7
+ import { SunoEmbed } from '../../mdx/suno-embed';
8
+
9
+ const ImageGrid = lazy(() =>
10
+ import('../../heavy/image-grid').then((mod) => ({ default: mod.ImageGrid })),
11
+ );
12
+ const ImageZoom = lazy(() =>
13
+ import('../../heavy/image-zoom').then((mod) => ({ default: mod.ImageZoom })),
14
+ );
15
+
16
+ export function createWidgetMdxComponents(
17
+ cdnBaseUrl?: string,
18
+ imageFallbackSrc?: string,
19
+ ): MDXComponents {
20
+ return {
21
+ TrophyCard,
22
+ ZiaCard,
23
+ GradientButton,
24
+ ZiaFile,
25
+ ZiaFolder,
26
+ SunoEmbed,
27
+ ImageGrid: (props) => (
28
+ <ImageGrid {...props} cdnBaseUrl={cdnBaseUrl} />
29
+ ),
30
+ ImageZoom: (props) => (
31
+ <ImageZoom {...props} fallbackSrc={imageFallbackSrc} />
32
+ ),
33
+ };
34
+ }
@@ -1,168 +1,6 @@
1
- import type { MDXComponents, MDXProps } from 'mdx/types';
2
- import type { ReactNode } from 'react';
3
- import { CodeBlock, Pre } from 'fumadocs-ui/components/codeblock';
4
- import { TypeTable } from 'fumadocs-ui/components/type-table';
5
- import {
6
- CSSIcon,
7
- CSVIcon,
8
- DiffIcon,
9
- HtmlIcon,
10
- HttpIcon,
11
- JavaIcon,
12
- JsonIcon,
13
- LogIcon,
14
- MDXIcon,
15
- RegexIcon,
16
- SQLIcon,
17
- SchemeIcon,
18
- SquareDashedBottomCodeIcon,
19
- TxtIcon,
20
- XMLIcon,
21
- YamlIcon,
22
- } from '@windrun-huaiin/base-ui/icons';
23
- import { baseMarkdownComponents } from '../share/markdown-component-map';
24
- import { Mermaid, ImageGrid, ImageZoom, MathBlock, InlineMath } from '../heavy';
25
- import { TrophyCard } from '../mdx/trophy-card';
26
- import { ZiaCard } from '../mdx/zia-card';
27
- import { GradientButton } from '../mdx/gradient-button';
28
- import { ZiaFile, ZiaFolder } from '../mdx/zia-file';
29
- import { SunoEmbed } from '../mdx/suno-embed';
30
-
31
- const defaultCodeLanguageIconMap: Record<string, ReactNode> = {
32
- css: <CSSIcon />,
33
- csv: <CSVIcon />,
34
- diff: <DiffIcon />,
35
- html: <HtmlIcon />,
36
- http: <HttpIcon />,
37
- java: <JavaIcon />,
38
- json: <JsonIcon />,
39
- jsonc: <SquareDashedBottomCodeIcon />,
40
- log: <LogIcon />,
41
- mdx: <MDXIcon />,
42
- plaintext: <TxtIcon />,
43
- regex: <RegexIcon />,
44
- scheme: <SchemeIcon />,
45
- sql: <SQLIcon />,
46
- text: <TxtIcon />,
47
- txt: <TxtIcon />,
48
- xml: <XMLIcon />,
49
- yaml: <YamlIcon />,
50
- yml: <YamlIcon />,
51
- };
52
-
53
- function tryToMatchIcon(
54
- props: Readonly<MDXProps & { 'data-language'?: string; title?: string }>,
55
- iconMap: Record<string, ReactNode>,
56
- ): ReactNode | undefined {
57
- let lang: string | undefined;
58
-
59
- const dataLanguage = props['data-language'] as string | undefined;
60
-
61
- if (dataLanguage && dataLanguage.trim() !== '') {
62
- lang = dataLanguage.trim().toLowerCase();
63
- } else {
64
- const title = props.title as string | undefined;
65
- if (title) {
66
- const titleParts = title.split('.');
67
- if (titleParts.length > 1 && titleParts[0] !== '') {
68
- const extension = titleParts.pop()?.toLowerCase();
69
- if (extension) {
70
- lang = extension;
71
- }
72
- }
73
- }
74
- }
75
-
76
- if (lang && iconMap[lang]) {
77
- return iconMap[lang];
78
- }
79
-
80
- return undefined;
81
- }
82
-
83
- export function createBaseMdxComponents(
84
- imageFallbackSrc?: string,
85
- ): MDXComponents {
86
- return {
87
- ...baseMarkdownComponents,
88
- img: (props) => (
89
- <ImageZoom
90
- {...(props as any)}
91
- fallbackSrc={imageFallbackSrc}
92
- />
93
- ),
94
- };
95
- }
96
-
97
- export function createCodeMdxComponents(
98
- iconMap: Record<string, ReactNode> = {},
99
- ): MDXComponents {
100
- const mergedIconMap = {
101
- ...defaultCodeLanguageIconMap,
102
- ...iconMap,
103
- };
104
-
105
- return {
106
- pre: (props) => {
107
- const customIcon = tryToMatchIcon(props as MDXProps & { 'data-language'?: string; title?: string }, mergedIconMap);
108
- return (
109
- <CodeBlock
110
- {...props}
111
- {...(customIcon && { icon: customIcon })}
112
- >
113
- <Pre>{props.children}</Pre>
114
- </CodeBlock>
115
- );
116
- },
117
- CodeBlock,
118
- Pre,
119
- };
120
- }
121
-
122
- export function createMathMdxComponents(): MDXComponents {
123
- return {
124
- MathBlock,
125
- InlineMath,
126
- };
127
- }
128
-
129
- export function createMermaidMdxComponents(
130
- watermarkEnabled?: boolean,
131
- watermarkText?: string,
132
- ): MDXComponents {
133
- return {
134
- Mermaid: (props) => (
135
- <Mermaid
136
- {...props}
137
- watermarkEnabled={watermarkEnabled}
138
- watermarkText={watermarkText}
139
- />
140
- ),
141
- };
142
- }
143
-
144
- export function createTypeTableMdxComponents(): MDXComponents {
145
- return {
146
- TypeTable,
147
- };
148
- }
149
-
150
- export function createWidgetMdxComponents(
151
- cdnBaseUrl?: string,
152
- imageFallbackSrc?: string,
153
- ): MDXComponents {
154
- return {
155
- TrophyCard,
156
- ZiaCard,
157
- GradientButton,
158
- ZiaFile,
159
- ZiaFolder,
160
- SunoEmbed,
161
- ImageGrid: (props) => (
162
- <ImageGrid {...props} cdnBaseUrl={cdnBaseUrl} />
163
- ),
164
- ImageZoom: (props) => (
165
- <ImageZoom {...props} fallbackSrc={imageFallbackSrc} />
166
- ),
167
- };
168
- }
1
+ export { createBaseMdxComponents } from './features/base';
2
+ export { createCodeMdxComponents } from './features/code';
3
+ export { createMathMdxComponents } from './features/math';
4
+ export { createMermaidMdxComponents } from './features/mermaid';
5
+ export { createTypeTableMdxComponents } from './features/type-table';
6
+ export { createWidgetMdxComponents } from './features/widgets';