Skip to content

Commit 7e3636b

Browse files
authored
chore: restore gen doc command (#7961)
1 parent 6a499b3 commit 7e3636b

File tree

10 files changed

+1112
-76
lines changed

10 files changed

+1112
-76
lines changed

packages/document/docs/en/guides/basic-features/render/ssg.mdx

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ export default defineConfig({
2727
});
2828
```
2929
30-
::::info Scope
30+
:::info
3131
- Use `output.ssg` for single-entry apps.
3232
- Use `output.ssgByEntries` for multi-entry apps.
3333
- If `output.ssg` is `true` and `output.ssgByEntries` is not set, all routes under all entries are treated as SSG routes.
34-
::::
34+
35+
:::
3536
3637
## Development Debugging
3738
@@ -92,36 +93,6 @@ Each route in **conventional routing** will generate a separate HTML file. Check
9293
9394
After running `pnpm run serve` to start the project, inspect the returned document in the Network tab of the browser's development tools. The document includes the fully rendered content from the component.
9495
95-
### Preventing Default Behavior
96-
97-
By default, all routes in **conventional routing** have SSG enabled. Modern.js provides another field to prevent the default SSG behavior.
98-
99-
For example, in the following directory structure, routes `/`, `/user`, and `/user/profile` all have SSG enabled:
100-
101-
```bash
102-
.
103-
├── src
104-
│ └── routes
105-
│ ├── layout.tsx
106-
│ ├── page.tsx
107-
│ └── user
108-
│ ├── layout.tsx
109-
│ ├── page.tsx
110-
│ └── profile
111-
│ └── page.tsx
112-
```
113-
114-
You can disable the default behavior of certain routes by configuring `preventDefault`. After configuring as shown below, only the SSG pages for `/` and `/user/profile` will be generated:
115-
116-
```js
117-
export default defineConfig({
118-
output: {
119-
ssg: {
120-
preventDefault: ['/user'],
121-
},
122-
},
123-
});
124-
```
12596
12697
## Using SSG in Manual Routing
12798

packages/document/docs/en/guides/concept/entries.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,15 @@ If you don't want to use any of Modern.js's runtime capabilities, you can also m
193193
194194
```js title=src/entry.tsx
195195
import React from 'react';
196-
import ReactDOM from 'react-dom';
196+
import { createRoot } from 'react-dom/client';
197197
import App from './App';
198198
199-
ReactDOM.render(<App />, document.getElementById('root'));
199+
const container = document.getElementById('root');
200+
201+
if (container) {
202+
const root = createRoot(container);
203+
root.render(<App />);
204+
}
200205
```
201206
202207
In this mode, **you will not be able to use Modern.js framework's runtime capabilities**, such as:
@@ -237,10 +242,6 @@ export default defineConfig({
237242
});
238243
```
239244
240-
It is worth noting that, by default, Modern.js considers entries specified through the configuration as **framework mode entries** and will automatically generate the actual compilation entry.
241-
242-
If your application is migrating from build tools like Webpack or Vite to the Modern.js framework, you typically need to enable the `disableMount` option in the entry configuration. In this case, Modern.js will treat the entry as a **build mode entry**.
243-
244245
## In-Depth
245246
246247
The concept of page entry is derived from the concept of [Entrypoint](https://webpack.js.org/concepts/entry-points/) in webpack. It is mainly used to configure JavaScript or other modules to be executed during application startup. webpack's [best practice](https://webpack.docschina.org/concepts/entry-points/#multi-page-application) for web applications usually corresponds entries to HTML output files, meaning each additional entry will eventually generate a corresponding HTML file in the output. The modules imported by the entry will be compiled and packaged into multiple Chunk outputs. For example, JavaScript modules may ultimately generate several file outputs similar to `dist/static/js/index.ea39u8.js`.

packages/document/docs/zh/guides/_meta.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,10 @@
2929
"name": "troubleshooting",
3030
"label": "troubleshooting"
3131
},
32-
"deprecated"
32+
"deprecated",
33+
{
34+
"type": "dir",
35+
"name": "upgrade",
36+
"label": "从 Modern.js 2.0 升级"
37+
}
3338
]

packages/document/docs/zh/guides/basic-features/data/data-cache.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ interface CacheOptions {
6767
## 使用范围
6868

6969
与 react 的 [cache](https://react.dev/reference/react/cache) 函数只能在 server component 组件中使用不同,
70-
EdenX 提供的 `cache` 函数可以在任意的前端或服务端的代码中使用。
70+
Modern.js 提供的 `cache` 函数可以在任意的前端或服务端的代码中使用。
7171

7272
## 详细用法
7373

packages/document/docs/zh/guides/basic-features/render/ssg.mdx

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ export default defineConfig({
2828
});
2929
```
3030

31-
::::info 适用范围
31+
:::info 适用范围
3232
- 单入口请使用 `output.ssg`
3333
- 多入口请使用 `output.ssgByEntries`
3434
- 当仅设置 `output.ssg: true` 且未配置 `output.ssgByEntries` 时,所有入口下的所有路由都会作为 SSG 路由处理。
35-
::::
35+
36+
:::
3637

3738
## 开发环境调试
3839

@@ -93,36 +94,6 @@ export default () => {
9394
9495
执行 `pnpm run serve` 启动项目后,访问页面,在浏览器我们工具的 Network 窗口,查看请求返回的文档,文档包含组件渲染后的完整页面内容。
9596
96-
### 阻止默认行为
97-
98-
默认情况下,**约定式路由**的路由会全部开启 SSG。Modern.js 提供了另一个字段,用来阻止默认的 SSG 行为。
99-
100-
例如以下目录结构,`/``/user``/user/profle` 三条路由都开启 SSG:
101-
102-
```bash
103-
.
104-
├── src
105-
│ └── routes
106-
│ ├── layout.tsx
107-
│ ├── page.tsx
108-
│ └── user
109-
│ ├── layout.tsx
110-
│ ├── page.tsx
111-
│ └── profile
112-
│ └── page.tsx
113-
```
114-
115-
可以通过配置 `preventDefault` 来禁用某些路由的默认行为。进行下面配置后,最终只会生成 `/``/user/profle` 两条路由的 SSG 页面:
116-
117-
```js
118-
export default defineConfig({
119-
output: {
120-
ssg: {
121-
preventDefault: ['/user'],
122-
},
123-
},
124-
});
125-
```
12697
12798
## 在自控式路由中使用
12899

packages/document/docs/zh/guides/concept/entries.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,18 @@ beforeRender().then(() => {
196196

197197
```js title=src/entry.tsx
198198
import React from 'react';
199-
import ReactDOM from 'react-dom';
199+
import { createRoot } from 'react-dom/client';
200200
import App from './App';
201201

202-
ReactDOM.render(<App />, document.getElementById('root'));
202+
const container = document.getElementById('root');
203+
204+
if (container) {
205+
const root = createRoot(container);
206+
root.render(<App />);
207+
}
203208
```
204209

210+
205211
在该模式下,**将无法使用 Modern.js 框架的运行时能力**,比如:
206212

207213
- 约定式路由,即基于 `src/routes` 下文件的路由
@@ -241,8 +247,6 @@ export default defineConfig({
241247
});
242248
```
243249

244-
值得注意的是,默认情况下,Modern.js 认为通过配置指定的入口是**框架模式入口**,将自动生成真正的编译入口。如果你的应用是从 Webpack 或 Vite 等构建工具迁移到 Modern.js 框架时,你通常需要在入口配置中开启 `disableMount` 选项,此时 Modern.js 认为该入口是**构建模式入口**
245-
246250
## 深入了解
247251

248252
页面入口的概念衍生自 webpack 的入口(Entrypoint)概念,其主要用于配置 JavaScript 或其他模块在应用启动时加载和执行。webpack 对于网页应用的 [最佳实践](https://webpack.docschina.org/concepts/entry-points/#multi-page-application) 通常将入口与 HTML 产物对应,即每增加一个入口最终就会在产物中生成一份对应的 HTML 文件。入口引入的模块会在编译打包后生成多个 Chunk 产物,例如对于 JavaScript 模块最终可能会生成数个类似 `dist/static/js/index.ea39u8.js` 的文件产物。
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["overview", "config", "entry"]

0 commit comments

Comments
 (0)