Skip to content

Commit

Permalink
i18n(zh-cn): Update configuration-reference.mdx (#8389)
Browse files Browse the repository at this point in the history
Co-authored-by: liruifengv <liruifeng1024@gmail.com>
  • Loading branch information
huyikai and liruifengv committed May 24, 2024
1 parent efc14b1 commit af5179a
Showing 1 changed file with 38 additions and 70 deletions.
108 changes: 38 additions & 70 deletions src/content/docs/zh-cn/reference/configuration-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,44 @@ $ astro build --root ./my-project-directory

使用 `'attribute'` 在你操作元素的 `class` 属性时很有用,这样你就可以避免你自己的样式逻辑和 Astro 的样式应用之间的冲突。

### security

<p>

**类型:** `boolean`<br />
**默认值:** `{}`<br />
<Since v="4.9.0" />
</p>

为 Astro 网站启用安全措施。

这些功能仅存在于使用 `server` 模式按需渲染的页面,或在 `hybrid` 模式中选择不进行预渲染的页面。

```js
// astro.config.mjs
export default defineConfig({
output: "server",
security: {
checkOrigin: true
}
})
```

#### security.checkOrigin

<p>

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

启用后,将检查所有现代浏览器自动传递的 "origin" 头是否与每个 `Request` 发送的 URL 匹配。这用于提供跨站请求伪造(CSRF)保护。

"origin" 检查仅对按需渲染的页面执行,并且仅对具有以下 `content-type` 头的 `POST``PATCH``DELETE``PUT` 请求执行:`'application/x-www-form-urlencoded'``'multipart/form-data'``'text/plain'`

如果 "origin" 头与请求的 `pathname` 不匹配,Astro 将返回 403 状态码,并不会渲染该页面。

### vite

<p>
Expand Down Expand Up @@ -1434,76 +1472,6 @@ export function Comment({ postId }: { postId: string }) {

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


### experimental.i18nDomains

<p>

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

启用域名支持,用于[实验性的 `domains` 路由策略](/zh-cn/guides/internationalization/#domains实验性功能),它允许你配置一个或多个支持的语言的 URL 模式,以使用自定义域名(或子域名)。

当一个语言环境映射到一个域名时,将不会使用 `/[locale]/` 路径前缀。然而,`src/pages/` 中的本地化文件夹仍然是必需的,包括你配置的 `defaultLocale`

其他未配置的语言环境将默认为根据你的 `prefixDefaultLocale` 策略进行本地化的路径 URL(例如 `https://example.com/[locale]/blog`)。

```js
//astro.config.mjs
export default defineConfig({
site: "https://example.com",
output: "server", // 不需要预渲染的页面
adapter: node({
mode: 'standalone',
}),
i18n: {
defaultLocale: "en",
locales: ["en", "fr", "pt-br", "es"],
prefixDefaultLocale: false,
domains: {
fr: "https://fr.example.com",
es: "https://example.es",
},
},
experimental: {
i18nDomains: true,
},
});
```

`astro:i18n` 辅助函数 [`getAbsoluteLocaleUrl()`](/zh-cn/reference/api-reference/#getabsolutelocaleurl)[`getAbsoluteLocaleUrlList()`](/zh-cn/reference/api-reference/#getabsolutelocaleurllist) 构建的页面路由和返回的 URL 将采用在 `i18n.domains` 中设置的选项。

查看 [国际化指南](/zh-cn/guides/internationalization/#domains实验性功能) 以获取更多细节,包括这个实验性功能的限制。

### experimental.security

<p>

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

为 Astro 网站启用 CSRF 保护。

CSRF 保护仅适用于按需渲染(服务端渲染)的页面,使用 `server``hybrid` 模式。在 `hybrid` 模式中,页面必须选择退出预渲染。

```js
// astro.config.mjs
export default defineConfig({
output: "server",
experimental: {
security: {
csrfProtection: {
origin: true
}
}
}
})
```

### experimental.rewriting

<p>
Expand Down

0 comments on commit af5179a

Please sign in to comment.