File tree 2 files changed +8
-81
lines changed
src/content/docs/zh-cn/guides/deploy
2 files changed +8
-81
lines changed Original file line number Diff line number Diff line change @@ -21,56 +21,19 @@ import { Steps } from '@astrojs/starlight/components';
21
21
22
22
你的 Astro 项目默认就是静态网站。你不需要任何额外的配置就可以将静态的 Astro 网站部署到 Netlify。
23
23
24
- ### SSR 适配器
24
+ ### 按需渲染适配器
25
25
26
- 通过以下的 ` astro add ` 命令,添加 [ Netlify 适配器] ( /zh-cn/guides/integrations-guide/netlify/ ) ,在你的 Astro 项目中启用 SSR 并部署到 Netlify。这一步将会安装适配器并且对你的 ` astro.config.mjs ` 文件进行适当的修改。
26
+ 通过以下的 ` astro add ` 命令,添加 [ Netlify 适配器] ( /zh-cn/guides/integrations-guide/netlify/ ) ,在你的 Astro 项目中启用按需渲染并部署到 Netlify。这一步将会安装适配器并且对你的 ` astro.config.mjs ` 文件进行适当的修改。
27
27
28
28
``` bash
29
29
npx astro add netlify
30
30
```
31
31
32
- 如果你更倾向于手动安装适配器,那么请完成以下两个步骤:
33
-
34
- <Steps >
35
- 1 . 使用你喜欢的包管理器将 [ @astrojs/netlify 适配器] ( /zh-cn/guides/integrations-guide/netlify/ ) 安装到你的项目依赖中。如果你正在使用 npm 或者不确定使用何种包管理器,可以在终端运行以下命令:
36
-
37
- ``` bash
38
- npm install @astrojs/netlify
39
- ```
40
-
41
- 2 . 在你的 ` astro.config.mjs ` 项目配置文件中添加两行新增内容:
42
-
43
- ``` js title="astro.config.mjs" ins={2, 5-6}
44
- import { defineConfig } from ' astro/config' ;
45
- import netlify from ' @astrojs/netlify' ;
46
-
47
- export default defineConfig ({
48
- output: ' server' ,
49
- adapter: netlify (),
50
- });
51
- ```
52
-
53
- 你还可使用 Netlify 的边缘函数部署你项目中的 Astro 中间件,即通过在 Netlify 适配器的配置中添加 ` edgeMiddleware: true ` :
54
-
55
- ``` diff lang="js"
56
- // astro.config.mjs
57
- import { defineConfig } from 'astro/config';
58
- import netlify from '@astrojs/netlify/functions';
59
-
60
- export default defineConfig({
61
- output: 'server',
62
- adapter: netlify({
63
- + edgeMiddleware: true
64
- }),
65
- });
66
- ```
67
-
68
- 要为预渲染页面运行中间件,请设置 ` edgeMiddleware: true ` 。这允许你使用中间件来实现身份验证、重定向或者其他类似的事情,同时仍然使用静态 HTML 输出。
69
- </Steps >
32
+ <ReadMore >如需手动安装或是查看关于配置选项的更多内容,例如使用 Netlify 的 Edge Function 来部署你项目中的 Astro 中间件,均可参见 [ Netlify 适配器指南] ( /zh-cn/guides/integrations-guide/netlify/ ) 。</ReadMore >
70
33
71
34
## 如何部署
72
35
73
- 你可以通过网站用户操作界面或使用 Netlify 的 CLI( 命令行工具) 进行部署。无论是静态网站还是 SSR 的 Astro 网站,其过程都是相同的。
36
+ 你可以通过网站用户操作界面或使用 Netlify 的 CLI( 命令行工具) 进行部署。无论是静态网站还是按需渲染的 Astro 网站,其过程都是相同的。
74
37
75
38
### 网站用户操作界面部署方式
76
39
Original file line number Diff line number Diff line change @@ -21,11 +21,9 @@ import { Steps } from '@astrojs/starlight/components';
21
21
22
22
默认情况下,你的 Astro 项目是一个静态站点。你无需任何额外配置即可将静态 Astro 站点部署到 Vercel。
23
23
24
- ### SSR 适配器
24
+ ### 按需渲染适配器
25
25
26
- 要在 Astro 项目中启用 SSR 并在 Vercel 上部署:
27
-
28
- 使用以下 ` astro add ` 命令为你的 Astro 项目中添加 [ Vercel 适配器] ( /zh-cn/guides/integrations-guide/vercel/ ) 以开启 SSR。此命令将安装适配器并同时自动对你的 ` astro.config.mjs ` 文件进行适当的配置。
26
+ 使用以下 ` astro add ` 命令为你的 Astro 项目中添加 [ Vercel 适配器] ( /zh-cn/guides/integrations-guide/vercel/ ) 以开启 [ 按需渲染] ( /zh-cn/guides/on-demand-rendering/ ) 。此命令将安装适配器并同时自动对你的 ` astro.config.mjs ` 文件进行适当的配置。
29
27
30
28
<PackageManagerTabs >
31
29
<Fragment slot = " npm" >
@@ -45,45 +43,11 @@ import { Steps } from '@astrojs/starlight/components';
45
43
</Fragment >
46
44
</PackageManagerTabs >
47
45
48
- 如果你更喜欢手动安装适配器,你需要完成以下两个步骤:
49
-
50
- <Steps >
51
- 1 . 使用你喜欢的包管理器将 [ ` @astrojs/vercel ` 适配器] ( /zh-cn/guides/integrations-guide/vercel/ ) 安装到项目的依赖项中。
52
-
53
- <PackageManagerTabs >
54
- <Fragment slot = " npm" >
55
- ``` shell
56
- npm install @astrojs/vercel
57
- ```
58
- </Fragment >
59
- <Fragment slot = " pnpm" >
60
- ``` shell
61
- pnpm add @astrojs/vercel
62
- ```
63
- </Fragment >
64
- <Fragment slot = " yarn" >
65
- ``` shell
66
- yarn add @astrojs/vercel
67
- ```
68
- </Fragment >
69
- </PackageManagerTabs >
70
-
71
- 2 . 在你的 ` astro.config.mjs ` 配置文件中添加以下配置。
72
-
73
- ``` js title="astro.config.mjs" ins={2, 5-6}
74
- import { defineConfig } from ' astro/config' ;
75
- import vercel from ' @astrojs/vercel' ;
76
-
77
- export default defineConfig ({
78
- output: ' server' ,
79
- adapter: vercel (),
80
- });
81
- ```
82
- </Steps >
46
+ <ReadMore >如需手动安装或是查看关于配置选项的更多内容,例如使用 Vercel 的 Edge Function 来部署你项目中的 Astro 中间件,均可参见 [ Vercel 适配器指南] ( /zh-cn/guides/integrations-guide/netlify/ ) 。</ReadMore >
83
47
84
48
## 如何部署
85
49
86
- 你可以通过 Vercel 的网站 UI 或使用 Vercel 提供的官方 CLI(命令行界面)部署 Astro 站点到 Vercel。部署静态站点和 SSR 站点的过程相同 。
50
+ 你可以通过 Vercel 的网站 UI 或使用 Vercel 提供的官方 CLI(命令行界面)部署 Astro 站点到 Vercel。部署静态站点和按需渲染站点的过程相同 。
87
51
88
52
### 通过网站 UI 部署
89
53
You can’t perform that action at this time.
0 commit comments