Skip to content

Commit

Permalink
chore: update document
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKam committed Sep 4, 2023
1 parent 049313d commit c36f719
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/vite-plugin-react-convention-routes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @orca-fe/vite-plugin-react-convention-routes

## 0.0.9

### Patch Changes

- chore: update document

## 0.0.8

### Patch Changes
Expand Down
22 changes: 20 additions & 2 deletions packages/vite-plugin-react-convention-routes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ ReactDOM.createRoot(document.getElementById('root')!).render(

### 动态路由

#### 兼容 [email protected] 的动态路由规则
#### 兼容 [[email protected]](https://umijs.org/docs/guides/routes#%E5%8A%A8%E6%80%81%E8%B7%AF%E7%94%B1) 的动态路由规则

`$` 前缀的目录或文件为动态路由。若 `$` 后不指定参数名,则代表 `*` 通配,比如:

* `src/pages/users/$id.tsx` 会成为 `/users/:id`
* `src/pages/users/$id/settings.tsx` 会成为 `/users/:id/settings`

#### 兼容 [email protected] 的动态路由规则
#### 兼容 [[email protected]](https://v3.umijs.org/docs/convention-routing) 的动态路由规则

约定 `[]` 包裹的文件或文件夹为动态路由。

Expand Down Expand Up @@ -132,3 +132,21 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
`umijs` 不同,你可以在 `src/pages` 目录下创建 `_layout.tsx`,作为全局的 `layout`。而不是 `src/layouts`


### 配置推荐

```javascript
// vite.config.js
import conventionRoutes from '@orca-fe/vite-plugin-react-convention-routes';
import { paramCase } from 'change-case';

export default {
plugins: [
conventionRoutes({
// 只扫描 404, index 和 _layout 文件,其他文件都不作为路由入口,这样可以避免一些不必要的路由生成,也使得路由更加清晰
filter: path => /^(.*\/)?(index|_layout|404)\.(j|t)sx?$/.test(path),
// 规范路由路径,避免出现大写字母和下划线
transform: paramCase,
}),
],
};
```
9 changes: 7 additions & 2 deletions packages/vite-plugin-react-convention-routes/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{
"name": "@orca-fe/vite-plugin-react-convention-routes",
"version": "0.0.8",
"version": "0.0.9",
"type": "module",
"description": "A vite plugin for react convention routes",
"keywords": [
"react",
"component"
"convention",
"routes",
"convention-routes",
"vite",
"plugin",
"umi"
],
"author": "NicoKam",
"license": "MIT",
Expand Down

0 comments on commit c36f719

Please sign in to comment.