Skip to content

Commit c05cd1a

Browse files
committed
fix: pages redirects
1 parent af73dc0 commit c05cd1a

File tree

11 files changed

+55
-14
lines changed

11 files changed

+55
-14
lines changed

content/docs/core/index.cn.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,22 +267,22 @@ const loginForm = defineForm({
267267

268268
<Cards>
269269
<Card
270-
href="/docs/core/field/defineField"
270+
href="/[lang]/docs/core/field/defineField"
271271
title="深入了解字段"
272272
description="学习字段定义、属性配置和生命周期管理"
273273
/>
274274
<Card
275-
href="/docs/core/validation"
275+
href="/[lang]/docs/core/field/validator"
276276
title="掌握表单验证"
277277
description="了解如何实现复杂的表单验证逻辑和自定义校验器"
278278
/>
279279
<Card
280-
href="/docs/core/relation"
280+
href="/[lang]/docs/core/relation/defineReaction"
281281
title="字段联动控制"
282282
description="掌握字段间的依赖关系和联动逻辑实现"
283283
/>
284284
<Card
285-
href="/docs/examples"
285+
href="/[lang]/docs/examples"
286286
title="查看示例"
287287
description="浏览更多实际项目中的表单使用案例"
288288
/>

content/docs/core/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,22 +278,22 @@ Congratulations! You have successfully created your first Signals Form. Now you
278278

279279
<Cards>
280280
<Card
281-
href="/docs/core/field/defineField"
281+
href="/[lang]/docs/core/field/defineField"
282282
title="Deep Dive into Fields"
283283
description="Learn field definition, property configuration, and lifecycle management"
284284
/>
285285
<Card
286-
href="/docs/core/validation"
286+
href="/[lang]/docs/core/field/validator"
287287
title="Master Form Validation"
288288
description="Learn how to implement complex form validation logic and custom validators"
289289
/>
290290
<Card
291-
href="/docs/core/relation"
291+
href="/[lang]/docs/core/relation/defineReaction"
292292
title="Field Linkage Control"
293293
description="Master dependencies between fields and implement linkage logic"
294294
/>
295295
<Card
296-
href="/docs/examples"
296+
href="/[lang]/docs/examples"
297297
title="View Examples"
298298
description="Browse more form usage cases from real projects"
299299
/>

next.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ const withMDX = createMDX();
66
const config = {
77
output: "export",
88
reactStrictMode: true,
9+
redirects(){
10+
return [
11+
{
12+
source: '/en',
13+
destination: '/',
14+
permanent: true,
15+
},
16+
]
17+
}
918
};
1019

1120
export default withMDX(config);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"build": "next build",
77
"dev": "next dev -p 4000 --turbo",
88
"start": "next start",
9+
"preview": "pnpx serve out",
910
"postinstall": "fumadocs-mdx"
1011
},
1112
"dependencies": {

src/app/[lang]/(home)/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export function ContactForm() {
196196
</p>
197197

198198
<div className="flex flex-col sm:flex-row gap-4 justify-center mb-12">
199-
<DynamicLink href="/cn/docs/core">
199+
<DynamicLink href={`/${resolvedParams.lang}/docs/core`}>
200200
<button
201201
type="button"
202202
className="cursor-pointer bg-black dark:bg-white text-white dark:text-black px-8 py-3 rounded-2xl font-semibold text-lg hover:bg-gray-800 dark:hover:bg-gray-100 transition-all duration-300"

src/app/[lang]/layout.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import "../../styles/global.css"
44
import type { ReactNode } from 'react';
55
import SearchDialog from "../../components/search"
66

7-
import { source } from '@/lib/source';
7+
import { i18n } from '@/lib/i18n';
8+
89
export function generateStaticParams() {
9-
return source.generateParams();
10+
return i18n.languages.map((lang) => ({
11+
lang,
12+
}));
1013
}
1114

1215
const inter = Inter({

src/components/card/index.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use client';
2+
import * as Primitive from 'fumadocs-ui/components/card';
3+
import { type ComponentProps, useMemo } from 'react';
4+
import { useParams } from 'next/navigation';
5+
6+
export const Cards = Primitive.Cards;
7+
export function Card({
8+
href,
9+
...props
10+
}: ComponentProps<typeof Primitive.Card>) {
11+
const { lang } = useParams();
12+
const processedHref = useMemo(
13+
() => href?.replaceAll('[lang]', lang as string),
14+
[href, lang],
15+
);
16+
17+
return <Primitive.Card href={processedHref} {...props} />;
18+
}

src/components/search/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import {
1313
import { useDocsSearch } from 'fumadocs-core/search/client';
1414
import { create } from '@orama/orama';
1515
import { useI18n } from 'fumadocs-ui/contexts/i18n';
16+
import { createTokenizer } from '@orama/tokenizers/mandarin';
1617

17-
function initOrama() {
18+
function initOrama(locale?: string) {
1819
return create({
1920
schema: { _: 'string' },
20-
// https://docs.orama.com/docs/orama-js/supported-languages
21-
language: 'english',
21+
components: {
22+
tokenizer: locale === 'cn' ? createTokenizer() : undefined,
23+
},
2224
});
2325
}
2426

src/lib/i18n.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import type { I18nConfig } from 'fumadocs-core/i18n';
33
export const i18n: I18nConfig = {
44
defaultLanguage: 'en',
55
languages: ['en', 'cn'],
6+
hideLocale: "never",
7+
fallbackLanguage: 'en',
68
};
79

810
export const languages = {

src/lib/source.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export const source = loader({
99
baseUrl: "/docs",
1010
i18n,
1111
source: docs.toFumadocsSource(),
12+
url(slugs, locale) {
13+
if (locale) return '/' + [locale, 'docs', ...slugs].join('/');
14+
return '/' + ['docs', ...slugs].join('/');
15+
},
1216
icon(icon) {
1317
if (!icon) {
1418
// You may set a default icon

0 commit comments

Comments
 (0)