Skip to content

Commit

Permalink
fix: route docs mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
zllkjc committed Jan 2, 2025
1 parent b49527a commit 76667c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ Files and directories named with `[]` are turned into dynamic routes. For instan
```bash
.
└── routes
├── [id]
│ └── page.tsx
├── blog
│ └── [id]
│ └── page.tsx
│ └── page.tsx
└── page.tsx
```

Expand Down Expand Up @@ -168,7 +169,7 @@ Files and directories named with `[$]` are turned into optional dynamic routes.
└── page.tsx
```

The `routes/user/[id$]/page.tsx` file will be converted to the `/user/:id?` route. All routes under `/user` will match this route, and the `id` parameter is optional. This route can be used to distinguish between **create** and **edit** actions.
The `routes/blog/[id$]/page.tsx` file will be converted to the `/blog/:id?` route. All routes under `/blog` will match this route, and the `id` parameter is optional. This route can be used to distinguish between **create** and **edit** actions.

```tsx
import { useParams } from '@modern-js/runtime/router';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ export default () => {
```bash
.
└── routes
├── [id]
│ └── page.tsx
├── blog
│   └── [id]
│   └── page.tsx
│ └── page.tsx
└── page.tsx
```

Expand Down Expand Up @@ -169,7 +170,7 @@ export default Blog;
└── page.tsx
```

`routes/user/[id$]/page.tsx` 文件会转为 `/user/:id?` 路由。`/user` 下的所有路由都会匹配到该路由,并且 `id` 参数可选存在。通常在区分**创建****编辑**时,可以使用该路由。
`routes/blog/[id$]/page.tsx` 文件会转为 `/blog/:id?` 路由。`/blog` 下的所有路由都会匹配到该路由,并且 `id` 参数可选存在。通常在区分**创建****编辑**时,可以使用该路由。

```tsx
import { useParams } from '@modern-js/runtime/router';
Expand Down

0 comments on commit 76667c1

Please sign in to comment.