@modern-js/main-doc 2.63.5 → 2.63.6
Sign up to get free protection for your applications and to get access to all the features.
- package/docs/en/guides/basic-features/routes.mdx +4 -3
- package/docs/en/plugin/plugin-system/hook-list.mdx +0 -22
- package/docs/zh/guides/basic-features/render/ssr.mdx +2 -2
- package/docs/zh/guides/basic-features/routes.mdx +4 -3
- package/docs/zh/plugin/plugin-system/hook-list.mdx +0 -22
- package/package.json +2 -2
@@ -135,9 +135,10 @@ Files and directories named with `[]` are turned into dynamic routes. For instan
|
|
135
135
|
```bash
|
136
136
|
.
|
137
137
|
└── routes
|
138
|
+
├── [id]
|
139
|
+
│ └── page.tsx
|
138
140
|
├── blog
|
139
|
-
│ └──
|
140
|
-
│ └── page.tsx
|
141
|
+
│ └── page.tsx
|
141
142
|
└── page.tsx
|
142
143
|
```
|
143
144
|
|
@@ -168,7 +169,7 @@ Files and directories named with `[$]` are turned into optional dynamic routes.
|
|
168
169
|
└── page.tsx
|
169
170
|
```
|
170
171
|
|
171
|
-
The `routes/
|
172
|
+
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.
|
172
173
|
|
173
174
|
```tsx
|
174
175
|
import { useParams } from '@modern-js/runtime/router';
|
@@ -12,28 +12,6 @@ In this chapter, all available Hooks are listed, and you can use the correspondi
|
|
12
12
|
|
13
13
|
The following are the common CLI Hooks that can be used in both Modern.js Framework and Modern.js Module.
|
14
14
|
|
15
|
-
### `beforeConfig`
|
16
|
-
|
17
|
-
- Functionality: Running tasks before the config process
|
18
|
-
- Execution phase: Before the config process
|
19
|
-
- Hook model: `AsyncWorkflow`
|
20
|
-
- Type: `AsyncWorkflow<void, void>`
|
21
|
-
- Example:
|
22
|
-
|
23
|
-
```ts
|
24
|
-
import type { CliPlugin } from '@modern-js/core';
|
25
|
-
|
26
|
-
export const myPlugin = (): CliPlugin => ({
|
27
|
-
setup(api) {
|
28
|
-
return {
|
29
|
-
beforeConfig: () => {
|
30
|
-
// do something
|
31
|
-
},
|
32
|
-
};
|
33
|
-
},
|
34
|
-
});
|
35
|
-
```
|
36
|
-
|
37
15
|
### `config`
|
38
16
|
|
39
17
|
- Functionality: Collect configuration
|
@@ -27,7 +27,7 @@ title: 服务端渲染(SSR)
|
|
27
27
|
|
28
28
|
## 开启 SSR
|
29
29
|
|
30
|
-
在
|
30
|
+
在 Modern.js 启用 SSR 非常简单,只需要设置 [`server.ssr`](/configure/app/server/ssr) 为 `true` 即可:
|
31
31
|
|
32
32
|
```ts title="modern.config.ts"
|
33
33
|
import { defineConfig } from '@modern-js/app-tools';
|
@@ -328,4 +328,4 @@ export default function Test() {
|
|
328
328
|
|
329
329
|
在浏览器端,这段代码不会造成任何问题,但是在 SSR 时,Middleware 实例会一直无法被销毁。每次渲染组件,调用 `epicMiddleware.run(rootEpic)` 时,都会在内部添加新的事件绑定,导致整个对象不断变大,最终对应用性能造成影响。
|
330
330
|
|
331
|
-
CSR 中这类问题不易被发觉,因此从 CSR 切换到 SSR 时,如果不确定应用是否存在这类隐患,可以对应用进行压测。
|
331
|
+
CSR 中这类问题不易被发觉,因此从 CSR 切换到 SSR 时,如果不确定应用是否存在这类隐患,可以对应用进行压测。
|
@@ -136,9 +136,10 @@ export default () => {
|
|
136
136
|
```bash
|
137
137
|
.
|
138
138
|
└── routes
|
139
|
+
├── [id]
|
140
|
+
│ └── page.tsx
|
139
141
|
├── blog
|
140
|
-
│
|
141
|
-
│ └── page.tsx
|
142
|
+
│ └── page.tsx
|
142
143
|
└── page.tsx
|
143
144
|
```
|
144
145
|
|
@@ -169,7 +170,7 @@ export default Blog;
|
|
169
170
|
└── page.tsx
|
170
171
|
```
|
171
172
|
|
172
|
-
`routes/
|
173
|
+
`routes/blog/[id$]/page.tsx` 文件会转为 `/blog/:id?` 路由。`/blog` 下的所有路由都会匹配到该路由,并且 `id` 参数可选存在。通常在区分**创建**与**编辑**时,可以使用该路由。
|
173
174
|
|
174
175
|
```tsx
|
175
176
|
import { useParams } from '@modern-js/runtime/router';
|
@@ -12,28 +12,6 @@ Modern.js 工程体系中包含三类插件:CLI、Runtime、Server,每一类
|
|
12
12
|
|
13
13
|
以下是通用的 CLI Hooks,可以在 Modern.js Framework 以及 Modern.js Module 中使用。
|
14
14
|
|
15
|
-
### `beforeConfig`
|
16
|
-
|
17
|
-
- 功能:运行收集配置前的任务
|
18
|
-
- 执行阶段:收集配置前
|
19
|
-
- Hook 模型:`AsyncWorkflow`
|
20
|
-
- 类型:`AsyncWorkflow<void, void>`
|
21
|
-
- 使用示例:
|
22
|
-
|
23
|
-
```ts
|
24
|
-
import type { CliPlugin } from '@modern-js/core';
|
25
|
-
|
26
|
-
export const myPlugin = (): CliPlugin => ({
|
27
|
-
setup(api) {
|
28
|
-
return {
|
29
|
-
beforeConfig: () => {
|
30
|
-
// do something
|
31
|
-
},
|
32
|
-
};
|
33
|
-
},
|
34
|
-
});
|
35
|
-
```
|
36
|
-
|
37
15
|
### `config`
|
38
16
|
|
39
17
|
- 功能:收集配置
|
package/package.json
CHANGED
@@ -15,14 +15,14 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.63.
|
18
|
+
"version": "2.63.6",
|
19
19
|
"publishConfig": {
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
21
21
|
"access": "public",
|
22
22
|
"provenance": true
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@modern-js/sandpack-react": "2.63.
|
25
|
+
"@modern-js/sandpack-react": "2.63.6"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"@rspress/shared": "1.39.3",
|