Skip to content

Commit 9783f53

Browse files
committed
feat: add locale switching for sidebar
1 parent cb6b711 commit 9783f53

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/.vitepress/sidebar.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import type { DefaultTheme } from "vitepress/types"
2+
import { Locale } from "./types"
23

34
export function projectSidebar(
4-
projectIndex: string
5+
projectIndex: string,
6+
locale?: Locale
57
): DefaultTheme.SidebarItem[] {
8+
const langTag = locale && locale != Locale.EN_GB ? `/${locale}` : ""
69
return [
7-
{ text: "Intro", link: `/projects/${projectIndex}/` },
8-
{ text: "Usage", link: `/projects/${projectIndex}/usage` },
9-
{ text: "API", link: `/projects/${projectIndex}/api` },
10-
{ text: "Changelog", link: `/projects/${projectIndex}/changelog` },
10+
{ text: "Intro", link: `${langTag}/projects/${projectIndex}/` },
11+
{ text: "Usage", link: `${langTag}/projects/${projectIndex}/usage` },
12+
{ text: "API", link: `${langTag}/projects/${projectIndex}/api` },
13+
{
14+
text: "Changelog",
15+
link: `${langTag}/projects/${projectIndex}/changelog`,
16+
},
1117
]
1218
}

src/.vitepress/types/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum Locale {
2+
EN_GB = "en-GB",
3+
ZH_CN = "zh-CN"
4+
}

0 commit comments

Comments
 (0)