@windrun-huaiin/third-ui 27.0.0 → 28.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.
- package/dist/fuma/base/custom-home-layout.d.ts +0 -5
- package/dist/fuma/base/docs-root-provider.d.ts +19 -0
- package/dist/fuma/base/docs-root-provider.js +17 -0
- package/dist/fuma/base/docs-root-provider.mjs +15 -0
- package/dist/fuma/base/index.d.ts +4 -0
- package/dist/fuma/base/index.js +12 -7
- package/dist/fuma/base/index.mjs +4 -1
- package/dist/fuma/base/site-docs-layout.d.ts +11 -0
- package/dist/fuma/base/site-docs-layout.js +15 -0
- package/dist/fuma/base/site-docs-layout.mjs +13 -0
- package/dist/fuma/base/site-home-layout.d.ts +24 -0
- package/dist/fuma/base/site-home-layout.js +16 -0
- package/dist/fuma/base/site-home-layout.mjs +14 -0
- package/dist/fuma/base/site-layout-shared.d.ts +89 -0
- package/dist/fuma/base/site-layout-shared.js +48 -0
- package/dist/fuma/base/site-layout-shared.mjs +42 -0
- package/dist/fuma/base/site-layout.d.ts +4 -120
- package/dist/fuma/fuma-page-genarator.js +5 -5
- package/dist/fuma/fuma-page-genarator.mjs +1 -1
- package/dist/fuma/server/llm-copy-handler.d.ts +2 -0
- package/dist/fuma/server/llm-copy-handler.js +7 -0
- package/dist/fuma/server/llm-copy-handler.mjs +1 -0
- package/dist/fuma/server/page-generator.d.ts +2 -0
- package/dist/fuma/server/page-generator.js +7 -0
- package/dist/fuma/server/page-generator.mjs +1 -0
- package/dist/lib/seo-metadata.js +3 -3
- package/dist/lib/seo-metadata.mjs +1 -1
- package/dist/lib/seo-util.js +4 -4
- package/dist/lib/seo-util.mjs +1 -1
- package/dist/main/credit/credit-nav-button.js +25 -1
- package/dist/main/credit/credit-nav-button.mjs +25 -1
- package/dist/main/footer.js +3 -3
- package/dist/main/footer.mjs +1 -1
- package/dist/main/money-price/money-price-button.js +2 -2
- package/dist/main/money-price/money-price-button.mjs +2 -2
- package/dist/main/money-price/money-price-interactive.d.ts +1 -1
- package/dist/main/money-price/money-price-interactive.js +14 -18
- package/dist/main/money-price/money-price-interactive.mjs +14 -18
- package/dist/main/money-price/money-price-types.d.ts +1 -0
- package/package.json +44 -4
- package/src/fuma/base/custom-header.tsx +1 -1
- package/src/fuma/base/custom-home-layout.tsx +0 -6
- package/src/fuma/base/docs-root-provider.tsx +58 -0
- package/src/fuma/base/index.ts +4 -0
- package/src/fuma/base/site-docs-layout.tsx +35 -0
- package/src/fuma/base/site-home-layout.tsx +78 -0
- package/src/fuma/base/site-layout-shared.tsx +190 -0
- package/src/fuma/base/site-layout.tsx +4 -295
- package/src/fuma/fuma-page-genarator.tsx +1 -1
- package/src/fuma/server/llm-copy-handler.ts +2 -0
- package/src/fuma/server/page-generator.ts +2 -0
- package/src/lib/seo-metadata.ts +1 -1
- package/src/lib/seo-util.ts +2 -2
- package/src/main/credit/credit-nav-button.tsx +36 -3
- package/src/main/footer.tsx +1 -2
- package/src/main/money-price/money-price-button.tsx +5 -3
- package/src/main/money-price/money-price-interactive.tsx +13 -15
- package/src/main/money-price/money-price-types.ts +1 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { DocsLayout, type DocsLayoutProps } from 'fumadocs-ui/layouts/docs';
|
|
3
|
+
import {
|
|
4
|
+
normalizeNavItems,
|
|
5
|
+
type SiteBaseLayoutConfig,
|
|
6
|
+
} from './site-layout-shared';
|
|
7
|
+
|
|
8
|
+
export interface SiteDocsLayoutConfig extends SiteBaseLayoutConfig {
|
|
9
|
+
tree: DocsLayoutProps['tree'];
|
|
10
|
+
sidebar?: DocsLayoutProps['sidebar'];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function toDocsLayoutOptions(config: SiteDocsLayoutConfig): DocsLayoutProps {
|
|
14
|
+
return {
|
|
15
|
+
...(config.nav ? { nav: config.nav } : {}),
|
|
16
|
+
...(config.i18n ? { i18n: config.i18n } : {}),
|
|
17
|
+
...(config.githubUrl ? { githubUrl: config.githubUrl } : {}),
|
|
18
|
+
...(config.links ? { links: normalizeNavItems(config.links) } : {}),
|
|
19
|
+
...(config.searchToggle ? { searchToggle: config.searchToggle } : {}),
|
|
20
|
+
...(config.themeSwitch ? { themeSwitch: config.themeSwitch } : {}),
|
|
21
|
+
...(config.sidebar ? { sidebar: config.sidebar } : {}),
|
|
22
|
+
tree: config.tree,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function SiteDocsLayout({
|
|
27
|
+
config,
|
|
28
|
+
children,
|
|
29
|
+
}: {
|
|
30
|
+
config: SiteDocsLayoutConfig;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}) {
|
|
33
|
+
const options = toDocsLayoutOptions(config);
|
|
34
|
+
return <DocsLayout {...options}>{children}</DocsLayout>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
CustomHomeLayout,
|
|
4
|
+
type CustomHomeLayoutProps,
|
|
5
|
+
type HeaderActionOrders,
|
|
6
|
+
} from './custom-home-layout';
|
|
7
|
+
import {
|
|
8
|
+
toHomeLayoutOptions,
|
|
9
|
+
type SiteBaseLayoutConfig,
|
|
10
|
+
} from './site-layout-shared';
|
|
11
|
+
|
|
12
|
+
export interface SiteHomeLayoutConfig extends SiteBaseLayoutConfig {
|
|
13
|
+
showBanner?: boolean;
|
|
14
|
+
bannerHeight?: number;
|
|
15
|
+
headerHeight?: number;
|
|
16
|
+
headerPaddingTop?: number;
|
|
17
|
+
navbarClassName?: string;
|
|
18
|
+
floatingNav?: boolean;
|
|
19
|
+
banner?: ReactNode;
|
|
20
|
+
footer?: ReactNode;
|
|
21
|
+
goToTop?: ReactNode;
|
|
22
|
+
showFooter?: boolean;
|
|
23
|
+
showGoToTop?: boolean;
|
|
24
|
+
actionOrders?: HeaderActionOrders;
|
|
25
|
+
localePrefixAsNeeded?: boolean;
|
|
26
|
+
defaultLocale?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function SiteHomeLayout({
|
|
30
|
+
locale,
|
|
31
|
+
config,
|
|
32
|
+
children,
|
|
33
|
+
}: {
|
|
34
|
+
locale: string;
|
|
35
|
+
config: SiteHomeLayoutConfig;
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
}) {
|
|
38
|
+
const {
|
|
39
|
+
actionOrders,
|
|
40
|
+
banner,
|
|
41
|
+
bannerHeight,
|
|
42
|
+
defaultLocale,
|
|
43
|
+
floatingNav,
|
|
44
|
+
footer,
|
|
45
|
+
goToTop,
|
|
46
|
+
headerHeight,
|
|
47
|
+
headerPaddingTop,
|
|
48
|
+
localePrefixAsNeeded,
|
|
49
|
+
navbarClassName,
|
|
50
|
+
showBanner,
|
|
51
|
+
showFooter,
|
|
52
|
+
showGoToTop,
|
|
53
|
+
...baseConfig
|
|
54
|
+
} = config;
|
|
55
|
+
|
|
56
|
+
const options = toHomeLayoutOptions(baseConfig);
|
|
57
|
+
|
|
58
|
+
const layoutProps: CustomHomeLayoutProps = {
|
|
59
|
+
locale,
|
|
60
|
+
options,
|
|
61
|
+
...(actionOrders ? { actionOrders } : {}),
|
|
62
|
+
...(banner ? { banner } : {}),
|
|
63
|
+
...(bannerHeight != null ? { bannerHeight } : {}),
|
|
64
|
+
...(defaultLocale ? { defaultLocale } : {}),
|
|
65
|
+
...(floatingNav != null ? { floatingNav } : {}),
|
|
66
|
+
...(footer ? { footer } : {}),
|
|
67
|
+
...(goToTop ? { goToTop } : {}),
|
|
68
|
+
...(headerHeight != null ? { headerHeight } : {}),
|
|
69
|
+
...(headerPaddingTop != null ? { headerPaddingTop } : {}),
|
|
70
|
+
...(localePrefixAsNeeded != null ? { localePrefixAsNeeded } : {}),
|
|
71
|
+
...(navbarClassName ? { navbarClassName } : {}),
|
|
72
|
+
...(showBanner != null ? { showBanner } : {}),
|
|
73
|
+
...(showFooter != null ? { showFooter } : {}),
|
|
74
|
+
...(showGoToTop != null ? { showGoToTop } : {}),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return <CustomHomeLayout {...layoutProps}>{children}</CustomHomeLayout>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { HomeLayoutProps } from 'fumadocs-ui/layouts/home';
|
|
3
|
+
import type { LinkItemType } from 'fumadocs-ui/layouts/shared';
|
|
4
|
+
|
|
5
|
+
export type ExtendedLinkItem = LinkItemType & {
|
|
6
|
+
mobilePinned?: boolean;
|
|
7
|
+
prefetch?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type SiteMenuConfig = HTMLAttributes<HTMLElement> & {
|
|
11
|
+
banner?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
interface SiteNavSharedFields {
|
|
15
|
+
secondary?: boolean;
|
|
16
|
+
mobilePinned?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface SiteNavLinkItemConfig extends SiteNavSharedFields {
|
|
20
|
+
type?: 'main' | 'icon' | 'button';
|
|
21
|
+
text: ReactNode;
|
|
22
|
+
url: string;
|
|
23
|
+
external?: boolean;
|
|
24
|
+
prefetch?: boolean;
|
|
25
|
+
icon?: ReactNode;
|
|
26
|
+
description?: ReactNode;
|
|
27
|
+
menu?: SiteMenuConfig;
|
|
28
|
+
on?: 'nav' | 'menu' | 'all';
|
|
29
|
+
label?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SiteNavMenuItemConfig extends SiteNavSharedFields {
|
|
33
|
+
type: 'menu';
|
|
34
|
+
text: ReactNode;
|
|
35
|
+
url?: string;
|
|
36
|
+
external?: boolean;
|
|
37
|
+
prefetch?: boolean;
|
|
38
|
+
icon?: ReactNode;
|
|
39
|
+
description?: ReactNode;
|
|
40
|
+
items: SiteNavItemConfig[];
|
|
41
|
+
menu?: SiteMenuConfig;
|
|
42
|
+
on?: 'nav' | 'menu' | 'all';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SiteNavCustomItemConfig extends SiteNavSharedFields {
|
|
46
|
+
type: 'custom';
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type SiteNavItemConfig =
|
|
51
|
+
| SiteNavLinkItemConfig
|
|
52
|
+
| SiteNavMenuItemConfig
|
|
53
|
+
| SiteNavCustomItemConfig;
|
|
54
|
+
|
|
55
|
+
export interface SiteBaseLayoutConfig {
|
|
56
|
+
nav?: HomeLayoutProps['nav'];
|
|
57
|
+
i18n?: HomeLayoutProps['i18n'];
|
|
58
|
+
githubUrl?: string;
|
|
59
|
+
links?: SiteNavItemConfig[];
|
|
60
|
+
searchToggle?: HomeLayoutProps['searchToggle'];
|
|
61
|
+
themeSwitch?: HomeLayoutProps['themeSwitch'];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface SiteMenuLeafConfig {
|
|
65
|
+
text: ReactNode;
|
|
66
|
+
path: string;
|
|
67
|
+
description?: ReactNode;
|
|
68
|
+
icon?: ReactNode;
|
|
69
|
+
className?: string;
|
|
70
|
+
external?: boolean;
|
|
71
|
+
prefetch?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface SiteMenuGroupConfig {
|
|
75
|
+
text: ReactNode;
|
|
76
|
+
path?: string;
|
|
77
|
+
prefetch?: boolean;
|
|
78
|
+
landing?: SiteMenuLeafConfig;
|
|
79
|
+
items: SiteMenuLeafConfig[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface CreateSiteNavItemContext {
|
|
83
|
+
resolveUrl: (path: string) => string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface CreateSiteNavGroupOptions {
|
|
87
|
+
featuredClassName?: string;
|
|
88
|
+
featuredBanner?: ReactNode;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface CreateSiteBaseLayoutOptions {
|
|
92
|
+
homeUrl: string;
|
|
93
|
+
title: ReactNode;
|
|
94
|
+
i18n?: HomeLayoutProps['i18n'];
|
|
95
|
+
githubUrl?: string;
|
|
96
|
+
transparentMode?: HomeLayoutProps['nav'] extends infer T
|
|
97
|
+
? T extends { transparentMode?: infer U }
|
|
98
|
+
? U
|
|
99
|
+
: never
|
|
100
|
+
: never;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function normalizeNavItems(items?: SiteNavItemConfig[]): ExtendedLinkItem[] | undefined {
|
|
104
|
+
if (!items) return undefined;
|
|
105
|
+
|
|
106
|
+
return items.map((item) => {
|
|
107
|
+
if (item.type === 'menu') {
|
|
108
|
+
return {
|
|
109
|
+
...item,
|
|
110
|
+
items: normalizeNavItems(item.items) ?? [],
|
|
111
|
+
} as ExtendedLinkItem;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return item as ExtendedLinkItem;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function createSiteNavLink(
|
|
119
|
+
item: SiteMenuLeafConfig,
|
|
120
|
+
context: CreateSiteNavItemContext,
|
|
121
|
+
): SiteNavLinkItemConfig {
|
|
122
|
+
return {
|
|
123
|
+
type: 'main',
|
|
124
|
+
text: item.text,
|
|
125
|
+
...(item.description ? { description: item.description } : {}),
|
|
126
|
+
url: context.resolveUrl(item.path),
|
|
127
|
+
...(item.external ? { external: item.external } : {}),
|
|
128
|
+
...(item.prefetch !== undefined ? { prefetch: item.prefetch } : {}),
|
|
129
|
+
...(item.icon || item.className
|
|
130
|
+
? {
|
|
131
|
+
menu: {
|
|
132
|
+
...(item.icon ? { banner: item.icon } : {}),
|
|
133
|
+
...(item.className ? { className: item.className } : {}),
|
|
134
|
+
},
|
|
135
|
+
}
|
|
136
|
+
: {}),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function createSiteNavGroup(
|
|
141
|
+
item: SiteMenuGroupConfig,
|
|
142
|
+
context: CreateSiteNavItemContext,
|
|
143
|
+
options?: CreateSiteNavGroupOptions,
|
|
144
|
+
): SiteNavMenuItemConfig {
|
|
145
|
+
return {
|
|
146
|
+
type: 'menu',
|
|
147
|
+
text: item.text,
|
|
148
|
+
...(item.path ? { url: context.resolveUrl(item.path) } : {}),
|
|
149
|
+
...(item.prefetch !== undefined ? { prefetch: item.prefetch } : {}),
|
|
150
|
+
items: [
|
|
151
|
+
...(item.landing
|
|
152
|
+
? [
|
|
153
|
+
{
|
|
154
|
+
...createSiteNavLink(item.landing, context),
|
|
155
|
+
menu: {
|
|
156
|
+
...(options?.featuredBanner ? { banner: options.featuredBanner } : {}),
|
|
157
|
+
className: options?.featuredClassName ?? 'md:row-span-2',
|
|
158
|
+
},
|
|
159
|
+
} satisfies SiteNavLinkItemConfig,
|
|
160
|
+
]
|
|
161
|
+
: []),
|
|
162
|
+
...item.items.map((child) => createSiteNavLink(child, context)),
|
|
163
|
+
],
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function createSiteBaseLayoutConfig(
|
|
168
|
+
options: CreateSiteBaseLayoutOptions,
|
|
169
|
+
): SiteBaseLayoutConfig {
|
|
170
|
+
return {
|
|
171
|
+
nav: {
|
|
172
|
+
url: options.homeUrl,
|
|
173
|
+
title: options.title,
|
|
174
|
+
transparentMode: options.transparentMode ?? 'none',
|
|
175
|
+
},
|
|
176
|
+
...(options.i18n ? { i18n: options.i18n } : {}),
|
|
177
|
+
...(options.githubUrl ? { githubUrl: options.githubUrl } : {}),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function toHomeLayoutOptions(config: SiteBaseLayoutConfig): HomeLayoutProps {
|
|
182
|
+
return {
|
|
183
|
+
...(config.nav ? { nav: config.nav } : {}),
|
|
184
|
+
...(config.i18n ? { i18n: config.i18n } : {}),
|
|
185
|
+
...(config.githubUrl ? { githubUrl: config.githubUrl } : {}),
|
|
186
|
+
...(config.links ? { links: normalizeNavItems(config.links) } : {}),
|
|
187
|
+
...(config.searchToggle ? { searchToggle: config.searchToggle } : {}),
|
|
188
|
+
...(config.themeSwitch ? { themeSwitch: config.themeSwitch } : {}),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -1,295 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { CustomHomeLayout, type CustomHomeLayoutProps, type ExtendedLinkItem, type HeaderActionOrders } from './custom-home-layout';
|
|
6
|
-
|
|
7
|
-
type RootProviderI18n = NonNullable<ComponentProps<typeof RootProvider>['i18n']>;
|
|
8
|
-
|
|
9
|
-
export interface DocsRootProviderProps {
|
|
10
|
-
i18n: RootProviderI18n;
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type SiteMenuConfig = HTMLAttributes<HTMLElement> & {
|
|
15
|
-
banner?: ReactNode;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
interface SiteNavSharedFields {
|
|
19
|
-
secondary?: boolean;
|
|
20
|
-
mobilePinned?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface SiteNavLinkItemConfig extends SiteNavSharedFields {
|
|
24
|
-
type?: 'main' | 'icon' | 'button';
|
|
25
|
-
text: ReactNode;
|
|
26
|
-
url: string;
|
|
27
|
-
external?: boolean;
|
|
28
|
-
prefetch?: boolean;
|
|
29
|
-
icon?: ReactNode;
|
|
30
|
-
description?: ReactNode;
|
|
31
|
-
menu?: SiteMenuConfig;
|
|
32
|
-
on?: 'nav' | 'menu' | 'all';
|
|
33
|
-
label?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface SiteNavMenuItemConfig extends SiteNavSharedFields {
|
|
37
|
-
type: 'menu';
|
|
38
|
-
text: ReactNode;
|
|
39
|
-
url?: string;
|
|
40
|
-
external?: boolean;
|
|
41
|
-
prefetch?: boolean;
|
|
42
|
-
icon?: ReactNode;
|
|
43
|
-
description?: ReactNode;
|
|
44
|
-
items: SiteNavItemConfig[];
|
|
45
|
-
menu?: SiteMenuConfig;
|
|
46
|
-
on?: 'nav' | 'menu' | 'all';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface SiteNavCustomItemConfig extends SiteNavSharedFields {
|
|
50
|
-
type: 'custom';
|
|
51
|
-
children: ReactNode;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export type SiteNavItemConfig =
|
|
55
|
-
| SiteNavLinkItemConfig
|
|
56
|
-
| SiteNavMenuItemConfig
|
|
57
|
-
| SiteNavCustomItemConfig;
|
|
58
|
-
|
|
59
|
-
export interface SiteBaseLayoutConfig {
|
|
60
|
-
nav?: HomeLayoutProps['nav'];
|
|
61
|
-
i18n?: HomeLayoutProps['i18n'];
|
|
62
|
-
githubUrl?: string;
|
|
63
|
-
links?: SiteNavItemConfig[];
|
|
64
|
-
searchToggle?: HomeLayoutProps['searchToggle'];
|
|
65
|
-
themeSwitch?: HomeLayoutProps['themeSwitch'];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface SiteHomeLayoutConfig extends SiteBaseLayoutConfig {
|
|
69
|
-
showBanner?: boolean;
|
|
70
|
-
bannerHeight?: number;
|
|
71
|
-
headerHeight?: number;
|
|
72
|
-
headerPaddingTop?: number;
|
|
73
|
-
navbarClassName?: string;
|
|
74
|
-
floatingNav?: boolean;
|
|
75
|
-
banner?: ReactNode;
|
|
76
|
-
footer?: ReactNode;
|
|
77
|
-
goToTop?: ReactNode;
|
|
78
|
-
showFooter?: boolean;
|
|
79
|
-
showGoToTop?: boolean;
|
|
80
|
-
actionOrders?: HeaderActionOrders;
|
|
81
|
-
localePrefixAsNeeded?: boolean;
|
|
82
|
-
defaultLocale?: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface SiteDocsLayoutConfig extends SiteBaseLayoutConfig {
|
|
86
|
-
tree: DocsLayoutProps['tree'];
|
|
87
|
-
sidebar?: DocsLayoutProps['sidebar'];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface SiteMenuLeafConfig {
|
|
91
|
-
text: ReactNode;
|
|
92
|
-
path: string;
|
|
93
|
-
description?: ReactNode;
|
|
94
|
-
icon?: ReactNode;
|
|
95
|
-
className?: string;
|
|
96
|
-
external?: boolean;
|
|
97
|
-
prefetch?: boolean;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface SiteMenuGroupConfig {
|
|
101
|
-
text: ReactNode;
|
|
102
|
-
path?: string;
|
|
103
|
-
prefetch?: boolean;
|
|
104
|
-
landing?: SiteMenuLeafConfig;
|
|
105
|
-
items: SiteMenuLeafConfig[];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface CreateSiteNavItemContext {
|
|
109
|
-
resolveUrl: (path: string) => string;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface CreateSiteNavGroupOptions {
|
|
113
|
-
featuredClassName?: string;
|
|
114
|
-
featuredBanner?: ReactNode;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface CreateSiteBaseLayoutOptions {
|
|
118
|
-
homeUrl: string;
|
|
119
|
-
title: ReactNode;
|
|
120
|
-
i18n?: HomeLayoutProps['i18n'];
|
|
121
|
-
githubUrl?: string;
|
|
122
|
-
transparentMode?: HomeLayoutProps['nav'] extends infer T
|
|
123
|
-
? T extends { transparentMode?: infer U }
|
|
124
|
-
? U
|
|
125
|
-
: never
|
|
126
|
-
: never;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function normalizeNavItems(items?: SiteNavItemConfig[]): ExtendedLinkItem[] | undefined {
|
|
130
|
-
if (!items) return undefined;
|
|
131
|
-
|
|
132
|
-
return items.map((item) => {
|
|
133
|
-
if (item.type === 'menu') {
|
|
134
|
-
return {
|
|
135
|
-
...item,
|
|
136
|
-
items: normalizeNavItems(item.items) ?? [],
|
|
137
|
-
} as ExtendedLinkItem;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return item as ExtendedLinkItem;
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function createSiteNavLink(
|
|
145
|
-
item: SiteMenuLeafConfig,
|
|
146
|
-
context: CreateSiteNavItemContext,
|
|
147
|
-
): SiteNavLinkItemConfig {
|
|
148
|
-
return {
|
|
149
|
-
type: 'main',
|
|
150
|
-
text: item.text,
|
|
151
|
-
...(item.description ? { description: item.description } : {}),
|
|
152
|
-
url: context.resolveUrl(item.path),
|
|
153
|
-
...(item.external ? { external: item.external } : {}),
|
|
154
|
-
...(item.prefetch !== undefined ? { prefetch: item.prefetch } : {}),
|
|
155
|
-
...(item.icon || item.className
|
|
156
|
-
? {
|
|
157
|
-
menu: {
|
|
158
|
-
...(item.icon ? { banner: item.icon } : {}),
|
|
159
|
-
...(item.className ? { className: item.className } : {}),
|
|
160
|
-
},
|
|
161
|
-
}
|
|
162
|
-
: {}),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export function createSiteNavGroup(
|
|
167
|
-
item: SiteMenuGroupConfig,
|
|
168
|
-
context: CreateSiteNavItemContext,
|
|
169
|
-
options?: CreateSiteNavGroupOptions,
|
|
170
|
-
): SiteNavMenuItemConfig {
|
|
171
|
-
return {
|
|
172
|
-
type: 'menu',
|
|
173
|
-
text: item.text,
|
|
174
|
-
...(item.path ? { url: context.resolveUrl(item.path) } : {}),
|
|
175
|
-
...(item.prefetch !== undefined ? { prefetch: item.prefetch } : {}),
|
|
176
|
-
items: [
|
|
177
|
-
...(item.landing
|
|
178
|
-
? [
|
|
179
|
-
{
|
|
180
|
-
...createSiteNavLink(item.landing, context),
|
|
181
|
-
menu: {
|
|
182
|
-
...(options?.featuredBanner ? { banner: options.featuredBanner } : {}),
|
|
183
|
-
className: options?.featuredClassName ?? 'md:row-span-2',
|
|
184
|
-
},
|
|
185
|
-
} satisfies SiteNavLinkItemConfig,
|
|
186
|
-
]
|
|
187
|
-
: []),
|
|
188
|
-
...item.items.map((child) => createSiteNavLink(child, context)),
|
|
189
|
-
],
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export function createSiteBaseLayoutConfig(
|
|
194
|
-
options: CreateSiteBaseLayoutOptions,
|
|
195
|
-
): SiteBaseLayoutConfig {
|
|
196
|
-
return {
|
|
197
|
-
nav: {
|
|
198
|
-
url: options.homeUrl,
|
|
199
|
-
title: options.title,
|
|
200
|
-
transparentMode: options.transparentMode ?? 'none',
|
|
201
|
-
},
|
|
202
|
-
...(options.i18n ? { i18n: options.i18n } : {}),
|
|
203
|
-
...(options.githubUrl ? { githubUrl: options.githubUrl } : {}),
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function toHomeLayoutOptions(config: SiteBaseLayoutConfig): HomeLayoutProps {
|
|
208
|
-
return {
|
|
209
|
-
...(config.nav ? { nav: config.nav } : {}),
|
|
210
|
-
...(config.i18n ? { i18n: config.i18n } : {}),
|
|
211
|
-
...(config.githubUrl ? { githubUrl: config.githubUrl } : {}),
|
|
212
|
-
...(config.links ? { links: normalizeNavItems(config.links) } : {}),
|
|
213
|
-
...(config.searchToggle ? { searchToggle: config.searchToggle } : {}),
|
|
214
|
-
...(config.themeSwitch ? { themeSwitch: config.themeSwitch } : {}),
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function toDocsLayoutOptions(config: SiteDocsLayoutConfig): DocsLayoutProps {
|
|
219
|
-
return {
|
|
220
|
-
...(config.nav ? { nav: config.nav } : {}),
|
|
221
|
-
...(config.i18n ? { i18n: config.i18n } : {}),
|
|
222
|
-
...(config.githubUrl ? { githubUrl: config.githubUrl } : {}),
|
|
223
|
-
...(config.links ? { links: normalizeNavItems(config.links) } : {}),
|
|
224
|
-
...(config.searchToggle ? { searchToggle: config.searchToggle } : {}),
|
|
225
|
-
...(config.themeSwitch ? { themeSwitch: config.themeSwitch } : {}),
|
|
226
|
-
...(config.sidebar ? { sidebar: config.sidebar } : {}),
|
|
227
|
-
tree: config.tree,
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export function DocsRootProvider({ i18n, children }: DocsRootProviderProps) {
|
|
232
|
-
return <RootProvider i18n={i18n}>{children}</RootProvider>;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export function SiteHomeLayout({
|
|
236
|
-
locale,
|
|
237
|
-
config,
|
|
238
|
-
children,
|
|
239
|
-
}: {
|
|
240
|
-
locale: string;
|
|
241
|
-
config: SiteHomeLayoutConfig;
|
|
242
|
-
children: ReactNode;
|
|
243
|
-
}) {
|
|
244
|
-
const {
|
|
245
|
-
actionOrders,
|
|
246
|
-
banner,
|
|
247
|
-
bannerHeight,
|
|
248
|
-
defaultLocale,
|
|
249
|
-
floatingNav,
|
|
250
|
-
footer,
|
|
251
|
-
goToTop,
|
|
252
|
-
headerHeight,
|
|
253
|
-
headerPaddingTop,
|
|
254
|
-
localePrefixAsNeeded,
|
|
255
|
-
navbarClassName,
|
|
256
|
-
showBanner,
|
|
257
|
-
showFooter,
|
|
258
|
-
showGoToTop,
|
|
259
|
-
...baseConfig
|
|
260
|
-
} = config;
|
|
261
|
-
|
|
262
|
-
const options = toHomeLayoutOptions(baseConfig);
|
|
263
|
-
|
|
264
|
-
const layoutProps: CustomHomeLayoutProps = {
|
|
265
|
-
locale,
|
|
266
|
-
options,
|
|
267
|
-
...(actionOrders ? { actionOrders } : {}),
|
|
268
|
-
...(banner ? { banner } : {}),
|
|
269
|
-
...(bannerHeight != null ? { bannerHeight } : {}),
|
|
270
|
-
...(defaultLocale ? { defaultLocale } : {}),
|
|
271
|
-
...(floatingNav != null ? { floatingNav } : {}),
|
|
272
|
-
...(footer ? { footer } : {}),
|
|
273
|
-
...(goToTop ? { goToTop } : {}),
|
|
274
|
-
...(headerHeight != null ? { headerHeight } : {}),
|
|
275
|
-
...(headerPaddingTop != null ? { headerPaddingTop } : {}),
|
|
276
|
-
...(localePrefixAsNeeded != null ? { localePrefixAsNeeded } : {}),
|
|
277
|
-
...(navbarClassName ? { navbarClassName } : {}),
|
|
278
|
-
...(showBanner != null ? { showBanner } : {}),
|
|
279
|
-
...(showFooter != null ? { showFooter } : {}),
|
|
280
|
-
...(showGoToTop != null ? { showGoToTop } : {}),
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
return <CustomHomeLayout {...layoutProps}>{children}</CustomHomeLayout>;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export function SiteDocsLayout({
|
|
287
|
-
config,
|
|
288
|
-
children,
|
|
289
|
-
}: {
|
|
290
|
-
config: SiteDocsLayoutConfig;
|
|
291
|
-
children: ReactNode;
|
|
292
|
-
}) {
|
|
293
|
-
const options = toDocsLayoutOptions(config);
|
|
294
|
-
return <DocsLayout {...options}>{children}</DocsLayout>;
|
|
295
|
-
}
|
|
1
|
+
export * from './docs-root-provider';
|
|
2
|
+
export * from './site-docs-layout';
|
|
3
|
+
export * from './site-home-layout';
|
|
4
|
+
export * from './site-layout-shared';
|
|
@@ -2,7 +2,7 @@ import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/page
|
|
|
2
2
|
import { ReactNode, ReactElement, cloneElement, type CSSProperties } from 'react';
|
|
3
3
|
import { TocFooterWrapper } from './mdx/toc-footer-wrapper';
|
|
4
4
|
import type { LLMCopyButtonProps, LLMCopyButton } from './mdx/toc-base';
|
|
5
|
-
import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib';
|
|
5
|
+
import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib/utils';
|
|
6
6
|
import { PortableClerkTOC, PortableClerkTOCTitle } from './mdx/toc-clerk-portable';
|
|
7
7
|
import { themeSvgIconColor } from '@windrun-huaiin/base-ui/lib';
|
|
8
8
|
|
package/src/lib/seo-metadata.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Metadata } from 'next';
|
|
2
2
|
import { getTranslations } from 'next-intl/server';
|
|
3
|
-
import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib';
|
|
3
|
+
import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib/utils';
|
|
4
4
|
|
|
5
5
|
export interface CreateLocalizedSiteMetadataOptions {
|
|
6
6
|
locale: string;
|
package/src/lib/seo-util.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MetadataRoute } from 'next';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib';
|
|
4
|
+
import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib/utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Generate robots.txt content
|
|
@@ -139,4 +139,4 @@ export function createSitemapHandler(
|
|
|
139
139
|
(sitemapHandler as any).dynamic = 'force-static';
|
|
140
140
|
|
|
141
141
|
return sitemapHandler;
|
|
142
|
-
}
|
|
142
|
+
}
|