@modern-js/main-doc 0.0.0-next-1679666804179 → 0.0.0-next-1679753199581

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # @modern-js/main-doc
2
2
 
3
- ## 0.0.0-next-1679666804179
3
+ ## 0.0.0-next-1679753199581
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - 304c9505c: fix: translate some chinese to english in en docs
8
8
  fix: 将部分英文文档中的中文翻译为英文
9
- - @modern-js/builder-doc@0.0.0-next-1679666804179
9
+ - @modern-js/builder-doc@0.0.0-next-1679753199581
10
10
 
11
11
  ## 2.10.0
12
12
 
@@ -49,6 +49,7 @@ However, developers still need to pay attention to the fallback of data, such as
49
49
  1. When you request the page on client-side page transitions, Modern.js sends an API request to the server, which runs Data Loader function.
50
50
 
51
51
  2. When using Data Loader, data fetching happens before rendering, Modern.js still supports fetching data when the component is rendered. See [Data Fetch](/guides/basic-features/data-fetch).
52
+
52
53
  :::
53
54
 
54
55
  ## Keep Rendering Consistent
@@ -80,7 +80,7 @@ Modern.js provides a set of APIs by default for projects to use:
80
80
  ```ts
81
81
  import { Middlewre } from '@modern-js/runtime/server';
82
82
 
83
- export const middleware = (context, next) => {
83
+ export const middleware: Middlewre = (context, next) => {
84
84
  const { source: { req, res } } = context;
85
85
  console.log(req.url);
86
86
  next();
@@ -48,6 +48,7 @@ Modern.js 打破传统的 SSR 开发模式,提供了用户无感的 SSR 开发
48
48
  1. 当以客户端路由的方式请求页面时,Modern.js 会发送一个 HTTP 请求,服务端接收到请求后执行页面对应的 Data Loader 函数,然后将执行结果作为请求的响应返回浏览器。
49
49
 
50
50
  2. 使用 Data Loader 时,数据获取发生在渲染前,Modern.js 也仍然支持在组件渲染时获取数据。更多相关内容可以查看[数据获取](/guides/basic-features/data-fetch)。
51
+
51
52
  :::
52
53
 
53
54
 
@@ -413,11 +414,11 @@ export default Page;
413
414
  从 Data Loader 文件导入类型时,需要使用 import type 语法,保证只导入类型信息,这样可以避免 Data Loader 的代码打包到前端产物的 bundle 文件中。
414
415
 
415
416
  所以,这里的导入方式为:`import type { Data } from './page.loader'`;
417
+
416
418
  :::
417
419
 
418
420
  也可以通过 `useAsyncValue` 获取 Data Loader 返回的异步数据。例如:
419
421
 
420
-
421
422
  ```tsx title='page.tsx'
422
423
  import { useAsyncValue } from '@modern-js/runtime/router';
423
424
 
@@ -48,15 +48,18 @@ Modern.js 提供的 Hook 用于控制 Web Server 中的内置逻辑,所有的
48
48
  目前提供了两种 Hook,分别是 `AfterMatch` 和 `AfterRender`,可以用于修改渲染结果。可以在 `server/index.ts` 中这样写:
49
49
 
50
50
  ```ts
51
- import type { AfterMatchHook, AfterRenderHook } from '@modern-js/runtime/server';
51
+ import type {
52
+ AfterMatchHook,
53
+ AfterRenderHook,
54
+ } from '@modern-js/runtime/server';
52
55
 
53
56
  export const afterMatch: AfterMatchHook = (ctx, next) => {
54
57
  next();
55
- }
58
+ };
56
59
 
57
60
  export const afterRender: AfterRenderHook = (ctx, next) => {
58
61
  next();
59
- }
62
+ };
60
63
  ```
61
64
 
62
65
  项目在使用 Hook 时,应该有以下最佳实践:
@@ -78,8 +81,10 @@ Modern.js 默认提供了一套 API 供项目使用:
78
81
  ```ts
79
82
  import { Middlewre } from '@modern-js/runtime/server';
80
83
 
81
- export const middleware = (context, next) => {
82
- const { source: { req, res } } = context;
84
+ export const middleware: Middlewre = (context, next) => {
85
+ const {
86
+ source: { req, res },
87
+ } = context;
83
88
  console.log(req.url);
84
89
  next();
85
90
  };
package/modern.config.ts CHANGED
@@ -152,5 +152,5 @@ export default defineConfig({
152
152
  }),
153
153
  ],
154
154
  },
155
- plugins: [docTools()],
155
+ plugins: [docTools({})],
156
156
  });
package/package.json CHANGED
@@ -11,13 +11,13 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-next-1679666804179",
14
+ "version": "0.0.0-next-1679753199581",
15
15
  "publishConfig": {
16
16
  "registry": "https://registry.npmjs.org/",
17
17
  "access": "public"
18
18
  },
19
19
  "peerDependencies": {
20
- "@modern-js/builder-doc": "0.0.0-next-1679666804179"
20
+ "@modern-js/builder-doc": "0.0.0-next-1679753199581"
21
21
  },
22
22
  "devDependencies": {
23
23
  "classnames": "^2",
@@ -29,9 +29,9 @@
29
29
  "fs-extra": "^10",
30
30
  "@types/node": "^16",
31
31
  "@types/fs-extra": "^9",
32
- "@modern-js/doc-tools": "0.0.0-next-1679666804179",
33
- "@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1679666804179",
34
- "@modern-js/builder-doc": "0.0.0-next-1679666804179"
32
+ "@modern-js/builder-doc": "0.0.0-next-1679753199581",
33
+ "@modern-js/doc-tools": "0.0.0-next-1679753199581",
34
+ "@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1679753199581"
35
35
  },
36
36
  "scripts": {
37
37
  "dev": "modern dev",