From e587ef1bd606e75c460501601887269f982673b7 Mon Sep 17 00:00:00 2001 From: 100gle Date: Mon, 6 Nov 2023 09:06:47 +0800 Subject: [PATCH] i18n(zh-cn): update `guides/deploy/gitlab.mdx` --- .../docs/zh-cn/guides/deploy/gitlab.mdx | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/content/docs/zh-cn/guides/deploy/gitlab.mdx b/src/content/docs/zh-cn/guides/deploy/gitlab.mdx index 6eeddd488fa0b..d49d6d23366e7 100644 --- a/src/content/docs/zh-cn/guides/deploy/gitlab.mdx +++ b/src/content/docs/zh-cn/guides/deploy/gitlab.mdx @@ -6,14 +6,15 @@ i18nReady: true 你可以使用 [GitLab Pages](https://pages.gitlab.io/) 为你的 [GitLab](https://about.gitlab.com/) 项目、组或用户账户托管 Astro 网站。 -:::tip[正在寻找示例?] +:::tip[正在寻找示例?] 看一看 [GitLab Pages 官方的 Astro 示例项目](https://gitlab.com/pages/astro)! ::: ## 如何部署 1. 在 `astro.config.mjs` 文件中设置正确的 `site`。 -2. 在 `astro.config.mjs` 文件中设置 `outDir:public`。这会告诉 Astro 将静态构建输出放在 `public` 目录下,该目录是 GitLab Pages 指定的静态资源存放位置。 +2. 将 `public/` 文件夹重命名为 `static`。 +3. 在 `astro.config.mjs` 文件中设置 `outDir:public`。这会告诉 Astro 将静态构建输出放在 `public` 目录下,该目录是 GitLab Pages 指定的静态资源存放位置。 如果你在 Astro 项目中使用 [`public/` 目录](/zh-cn/core-concepts/project-structure/#public) 存放静态资源,你需要重命名该目录,并在 `astro.config.mjs` 文件中将 `publicDir` 的值改为新的目录名。 @@ -23,36 +24,35 @@ i18nReady: true import { defineConfig } from 'astro/config'; export default defineConfig({ - sitemap: true, - site: 'https://astro.build/', + site: 'https://.gitlab.io', + base: '/' outDir: 'public', publicDir: 'static', }); ``` -3. 在项目根目录下创建一个名为 `.gitlab-ci.yml` 的文件,文件内容如下。这样,每当你对项目内容作出更改,该文件便会自动构建并部署你的站点。 +4. 在项目根目录下创建一个名为 `.gitlab-ci.yml` 的文件,文件内容如下。这样,每当你对项目内容作出更改,该文件便会自动构建并部署你的站点。 ```yaml - # 用于构建你的应用的Docker镜像 + # 用于构建你的应用的 Docker 镜像 image: node:lts - - pages: - cache: - paths: - - node_modules/ - script: - # 在这里指定构建你的应用所需的步骤 - - npm install - - npm run build - - artifacts: - paths: - # 包含用于发布的构建文件的文件夹 - # 必须命名为"public" - - public - - only: - # 仅在推送到以下分支时, - # 触发新的构建和部署 - - main + + before_script: + - npm ci + + pages: + script: + # 在这里指定构建你的应用所需的步骤 + - npm run build + + artifacts: + paths: + # 包含用于发布的构建文件的文件夹 + # 必须命名为"public" + - public + + only: + # 仅在推送到以下分支时, + # 触发新的构建和部署 + - main ```