Skip to content

Commit f34ca51

Browse files
committed
fix(docs): 修正 app/docs 下的路径错误
1 parent 2e7fab1 commit f34ca51

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

apps/docs/src/components/overview.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ export default function Overview(prefix: string): JSX.Element {
6363

6464
// 生成 Drawer 组件的侧边栏菜单
6565
export function buildMenus(l: Locale, prefix: string): Array<Menu.MenuItem> {
66+
if (!prefix.endsWith('/')) {
67+
prefix += '/';
68+
}
69+
6670
const menus: Array<Menu.MenuItem> = [
67-
{ type: 'a', label: l.t('_d.demo.overview'), value: `${prefix}/`, suffix: routes.length }, // 指向 overview
71+
{ type: 'a', label: l.t('_d.demo.overview'), value: prefix, suffix: routes.length }, // 指向 overview
6872
{ type: 'group', label: l.t('_d.demo.general'), items: [] },
6973
{ type: 'group', label: l.t('_d.demo.layout'), items: [] },
7074
{ type: 'group', label: l.t('_d.demo.navigation'), items: [] },

apps/docs/src/docs/docs.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ const advanceAPI = import.meta.glob('./advance/api.*.json', { eager: true, impor
2727
const routes: Array<RouteDefinition & { kind: Kind }> = [
2828
{
2929
kind: 'intro',
30-
path: ['/', '/intro/readme'],
30+
path: ['', 'intro/readme'],
3131
info: { title: '_d.docs.intro' },
3232
component: () => (
3333
<Doc articles={import.meta.glob('../../../../README.md', { eager: true, query: '?raw', import: 'default' })} />
3434
),
3535
},
3636
{
3737
kind: 'intro',
38-
path: '/intro/changelog',
38+
path: 'intro/changelog',
3939
info: { title: '_d.docs.changelog' },
4040
component: () => (
4141
<Doc articles={import.meta.glob('../../../../CHANGELOG.md', { eager: true, query: '?raw', import: 'default' })} />
@@ -46,7 +46,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
4646

4747
{
4848
kind: 'usage',
49-
path: '/usage/install',
49+
path: 'usage/install',
5050
info: { title: '_d.docs.install' },
5151
component: () => (
5252
<Doc
@@ -57,7 +57,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
5757
},
5858
{
5959
kind: 'usage',
60-
path: '/usage/platform',
60+
path: 'usage/platform',
6161
info: { title: '_d.docs.platform' },
6262
component: () => (
6363
<Doc
@@ -68,7 +68,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
6868
},
6969
{
7070
kind: 'usage',
71-
path: '/usage/svg',
71+
path: 'usage/svg',
7272
info: { title: '_d.docs.svg' },
7373
component: () => (
7474
<Doc
@@ -79,7 +79,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
7979
},
8080
{
8181
kind: 'usage',
82-
path: '/usage/theme',
82+
path: 'usage/theme',
8383
info: { title: '_d.docs.theme' },
8484
component: () => (
8585
<Doc
@@ -90,7 +90,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
9090
},
9191
{
9292
kind: 'usage',
93-
path: '/usage/faq',
93+
path: 'usage/faq',
9494
info: { title: '_d.docs.faq' },
9595
component: () => (
9696
<Doc
@@ -104,7 +104,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
104104

105105
{
106106
kind: 'advance',
107-
path: '/advance/locale',
107+
path: 'advance/locale',
108108
info: { title: '_d.docs.locale' },
109109
component: () => (
110110
<Doc
@@ -115,7 +115,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
115115
},
116116
{
117117
kind: 'advance',
118-
path: '/advance/validator',
118+
path: 'advance/validator',
119119
info: { title: '_d.docs.validator' },
120120
component: () => (
121121
<Doc
@@ -126,7 +126,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
126126
},
127127
{
128128
kind: 'advance',
129-
path: '/advance/error',
129+
path: 'advance/error',
130130
info: { title: '_d.docs.error' },
131131
component: () => (
132132
<Doc
@@ -137,7 +137,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
137137
},
138138
{
139139
kind: 'advance',
140-
path: '/advance/custom-theme',
140+
path: 'advance/custom-theme',
141141
info: { title: '_d.docs.customTheme' },
142142
component: () => (
143143
<Doc
@@ -148,7 +148,7 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
148148
},
149149
{
150150
kind: 'advance',
151-
path: '/advance/plugins',
151+
path: 'advance/plugins',
152152
info: { title: '_d.docs.plugins' },
153153
component: () => (
154154
<Doc
@@ -161,6 +161,10 @@ const routes: Array<RouteDefinition & { kind: Kind }> = [
161161

162162
// 生成 Drawer 组件的侧边栏菜单
163163
export function buildMenus(l: Locale, prefix: string): Array<Menu.MenuItem> {
164+
if (!prefix.endsWith('/')) {
165+
prefix += '/';
166+
}
167+
164168
const menus: Array<Menu.Group> = [
165169
{ type: 'group', label: l.t('_d.docs.intro'), items: [] },
166170
{ type: 'group', label: l.t('_d.docs.usage'), items: [] },
@@ -265,6 +269,10 @@ function Doc(props: DocProps): JSX.Element {
265269
* 提供了文档浏览的路由定义
266270
*/
267271
export function buildRoute(prefix: string, setDrawer: Setter<Drawer.RootRef | undefined>): RouteDefinition {
272+
if (!prefix.endsWith('/')) {
273+
prefix += '/';
274+
}
275+
268276
return {
269277
path: prefix,
270278
component: (props: ParentProps) => {

0 commit comments

Comments
 (0)