Skip to content

Commit

Permalink
Merge branch 'main' into config-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
yanthomasdev committed Sep 16, 2024
2 parents 5cc66e9 + 6b6cf4d commit 0721fa6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 71 deletions.
4 changes: 2 additions & 2 deletions src/content/docs/fr/reference/configuration-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ const countries = defineCollection({
export const collections = { countries };
```

Pour une logique de chargement plus avancée, vous pouvez définir un chargeur d'objets. Cela permet des mises à jour incrémentielles et un chargement conditionnel tout en offrant un accès complet au magasin de données. Consultez l'API dans [la RFC de l'API Content Layer](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md#loaders).
Pour une logique de chargement plus avancée, vous pouvez définir un chargeur d'objets. Cela permet des mises à jour incrémentielles et un chargement conditionnel tout en offrant un accès complet au magasin de données. Consultez l'API dans [la RFC de l'API Content Layer](https://github.com/withastro/roadmap/blob/content-layer/proposals/0050-content-layer.md#loaders).

#### Migration d'une collection de contenu existante pour utiliser l'API Content Layer

Expand Down Expand Up @@ -1765,4 +1765,4 @@ Vous pouvez convertir une collection de contenu existante avec des entrées Mark

#### En savoir plus

Pour retrouver une présentation complète et la référence détaillée de l'API, consultez [le RFC de l'API de la couche de contenu](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md) et [partagez vos commentaires](https://github.com/withastro/roadmap/pull/982).
Pour retrouver une présentation complète et la référence détaillée de l'API, consultez [le RFC de l'API de la couche de contenu](https://github.com/withastro/roadmap/blob/content-layer/proposals/0050-content-layer.md) et [partagez vos commentaires](https://github.com/withastro/roadmap/pull/982).
82 changes: 13 additions & 69 deletions src/content/docs/zh-cn/reference/configuration-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export default defineConfig({
**类型**`string`
</p>

你要部署到的基本路径。Astro 在开发过程中会匹配这个路径名,这样你的开发环境就会尽可能地与你的构建环境匹配。在下面的例子中,`astro dev` 会在 `/docs` 处启动你的服务器。
你要部署到的基本路径。Astro 在开发过程中会匹配这个路径名,这样你的开发环境就会尽可能地与你的构建环境匹配。

在下面的例子中,`astro dev` 会在 `/docs` 处启动你的服务器。

```js
{
Expand Down Expand Up @@ -160,8 +162,8 @@ export default defineConfig({

指定构建的输出目标。

- `static`- 构建静态网站,部署到任何静态托管服务器上
- `server` - 构建应用,部署到支持 SSR(服务器端渲染)的托管服务器上
- `static`- 构建静态网站,部署到任何静态托管服务器上
- `server` - 构建应用,部署到支持 SSR(服务器端渲染)的托管服务器上
- `hybrid` - 构建包含少量服务端渲染页面的静态网站。

```js
Expand All @@ -185,7 +187,7 @@ export default defineConfig({

使用构建适配器将其部署到你最喜爱的服务器、无服务器或边缘主机。导入我们的第一方适配器 [Netlify](/zh-cn/guides/deploy/netlify/#ssr-适配器)[Vercel](/zh-cn/guides/deploy/vercel/#ssr-适配器),以及更多的适配器来使用 Astro SSR。

[有关 SSR 的更多信息,请参见我们的服务器端渲染指南](/zh-cn/guides/server-side-rendering/),以及[我们的部署指南](/zh-cn/guides/deploy/)以获得完整的主机列表。
有关 SSR 的更多信息,[请参见我们的服务器端渲染指南](/zh-cn/guides/server-side-rendering/),以及[我们的部署指南](/zh-cn/guides/deploy/)以获得完整的主机列表。

```js
import netlify from '@astrojs/netlify';
Expand Down Expand Up @@ -604,9 +606,7 @@ export default defineConfig({
<Since v="2.6.0" />
</p>

指定是否在构建期间将重定向输出到 HTML 中。

此选项仅适用于 `output: 'static'` 模式;在 SSR 中,重定向会被作为和其他响应一样对待。
指定是否在构建期间将重定向输出到 HTML 中。此选项仅适用于 `output: 'static'` 模式;在 SSR 中,重定向会被作为和其他响应一样对待。

此选项主要适用于具有用于重定向的特殊配置文件且不需要(或不希望)基于 HTML 的重定向的适配器。

Expand Down Expand Up @@ -901,10 +901,10 @@ prefetch: {

`remotePatterns` 可以通过以下四个属性进行配置:

1. `protocol`
2. `hostname`
3. `port`
4. `pathname`
1. protocol
2. hostname
3. port
4. pathname

```js
{
Expand Down Expand Up @@ -1361,64 +1361,8 @@ Astro 提供了实验性标志,以便用户提前使用新功能。这些标
- `/blog/post/0` 由文件基础路由 `/blog/post/[pid]` 构建(而不是注入路由 `/blog/[...slug]`
- `/posts` 由重定向到 `/blog` 构建(而不是文件基础路由 `/[page]`


在路由冲突的情况下,两个具有相同路由优先级的路由试图构建相同的 URL,Astro 将记录警告,标识出冲突的路由。

### experimental.rewriting

<p>

**类型:** `boolean`<br />
**默认值:** `false`<br />
<Since v="4.8.0" />
</p>

启用一个路由功能,用于在 Astro 页面、端点和 Astro 中间件中重写请求,使你可以对路由进行编程控制。

```js
{
experimental: {
rewriting: true,
},
}
```

在你的 `.astro` 文件中使用 `Astro.rewrite` 来重定向到不同的页面:

```astro "rewrite"
---
// src/pages/dashboard.astro
if (!Astro.props.allowed) {
return Astro.rewrite("/")
}
---
```

在你的端点文件中使用 `context.rewrite` 来重定向到不同的页面:

```js
// src/pages/api.js
export function GET(ctx) {
if (!ctx.locals.allowed) {
return ctx.rewrite("/")
}
}
```

在你的中间件文件中使用 `next("/")` 来重定向到不同的页面,然后调用下一个中间件函数:

```js
// src/middleware.js
export function onRequest(ctx, next) {
if (!ctx.cookies.get("allowed")) {
return next("/") // 新签名
}
return next();
}
```

要全面了解并对这个实验性 API 提供反馈,请查看 [Rerouting RFC](https://github.com/withastro/roadmap/blob/feat/reroute/proposals/0047-rerouting.md)

### experimental.env

<p>
Expand Down Expand Up @@ -1771,7 +1715,7 @@ const countries = defineCollection({
export const collections = { countries };
```

对于更高级的加载逻辑,你可以定义一个 loader 对象。这允许增量更新和条件加载,同时还可以完全访问数据存储。请查看 [Content Layer API RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md#loaders) 中的 API。
对于更高级的加载逻辑,你可以定义一个 loader 对象。这允许增量更新和条件加载,同时还可以完全访问数据存储。请查看 [Content Layer API RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0050-content-layer.md#loaders) 中的 API。

#### 迁移现有内容集合以使用 Content Layer API

Expand Down Expand Up @@ -1835,4 +1779,4 @@ export const collections = { countries };

#### 了解更多

要全面了解并 [对这个实验性 API 提供反馈](https://github.com/withastro/roadmap/pull/982),请查看 [Content Layer API RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md)。
要全面了解并 [对这个实验性 API 提供反馈](https://github.com/withastro/roadmap/pull/982),请查看 [Content Layer API RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0050-content-layer.md)。

0 comments on commit 0721fa6

Please sign in to comment.