Skip to content

Commit 37fb997

Browse files
committed
feat(home): add language selection navigation for multilingual support
- Introduced a language selection navigation bar on the home page. - Supported languages include English, Simplified Chinese, Traditional Chinese, Japanese, French, Spanish, Portuguese, Korean, Malay, Indonesian, and Russian. - Enhanced user experience by allowing quick language switching.
1 parent 590c5cb commit 37fb997

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ export default async function HomePage({
6666
params: Promise<{ lang: string }>;
6767
}) {
6868
const lang = (await params).lang as keyof typeof texts;
69+
// 支持的语言及显示名
70+
const languages = [
71+
{ code: 'en', label: 'English' },
72+
{ code: 'zh-Hans', label: '简体中文' },
73+
{ code: 'zh-Hant', label: '繁體中文' },
74+
{ code: 'ja', label: '日本語' },
75+
{ code: 'fr', label: 'Français' },
76+
{ code: 'es', label: 'Español' },
77+
{ code: 'pt', label: 'Português' },
78+
{ code: 'ko', label: '한국어' },
79+
{ code: 'ms', label: 'Melayu' },
80+
{ code: 'id', label: 'Bahasa Indonesia' },
81+
{ code: 'ru', label: 'Русский' },
82+
];
6983
// 获取指定语言的页面
7084
const allBlogs = source.getPages(lang);
7185

@@ -89,7 +103,22 @@ export default async function HomePage({
89103
return (
90104
<main className="flex flex-1 flex-col px-6 py-8">
91105
<div className="max-w-6xl mx-auto w-full">
92-
106+
{/* 多语言快捷跳转栏 */}
107+
<nav className="flex flex-wrap gap-2 mb-8">
108+
{languages.map((item) => (
109+
<Link
110+
key={item.code}
111+
href={`/${item.code}`}
112+
className={`px-3 py-1 rounded-md text-sm transition-colors ${
113+
lang === item.code
114+
? 'bg-fd-primary text-fd-primary-foreground'
115+
: 'bg-fd-secondary text-fd-secondary-foreground hover:bg-fd-accent'
116+
}`}
117+
>
118+
{item.label}
119+
</Link>
120+
))}
121+
</nav>
93122
{blogs.length === 0 ? (
94123
<p className="text-fd-muted-foreground">
95124
{t.noBlogsMessage}

0 commit comments

Comments
 (0)