Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n(zh-cn): update some docs from 4.14 #9142

Merged
merged 5 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const myVariable = env.MY_VARIABLE;
你可以使用 `Runtime` 来为 `runtime` 对象添加类型:

```ts title="src/env.d.ts"
/// <reference types="astro/client" />
/// <reference path="../.astro/types.d.ts" />

type Runtime = import('@astrojs/cloudflare').Runtime<Env>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ const {

```ts title="src/env.d.ts"
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />

type NetlifyLocals = import('@astrojs/netlify').NetlifyLocals

Expand Down
7 changes: 6 additions & 1 deletion src/content/docs/zh-cn/guides/integrations-guide/vercel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ export default defineConfig({

### 函数打包配置

:::caution[已废弃]
`functionPerRoute` 选项已被弃用,并将在 Astro 5 中完全删除。此外,此选项与一些 Astro 功能不兼容,例如 i18n 域和请求重写。

如果你当前已启用 `functionPerRoute: true`,我们建议尽快删除此配置选项。
:::

Vercel 适配器默认将所有路由组合成一个函数。

你也可以使用 `functionPerRoute` 选项将构建拆分为每个路由一个函数。这样可以减少每个函数的大小,这意味着你不太可能超过单个函数的大小限制。并且,代码启动更快。
Expand Down Expand Up @@ -419,7 +425,6 @@ export default defineConfig({

```ts
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />

type EdgeLocals = import('@astrojs/vercel').EdgeLocals

Expand Down
3 changes: 2 additions & 1 deletion src/content/docs/zh-cn/guides/middleware.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export const onRequest = (context, next) => {
要给 `Astro.locals` 内的信息定义类型,也就是在 `.astro` 文件和中间件代码中能提供自动补全,在 `env.d.ts` 文件中声明一个全局命名空间:

```ts title="src/env.d.ts"
/// <reference types="astro/client" />
/// <reference path="../.astro/types.d.ts" />

declare namespace App {
interface Locals {
user: {
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/zh-cn/guides/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Astro 中包含三个可扩展的 `tsconfig.json` 模板:`base`、`strict` 和
此外,我们的模板在 `src` 文件夹中包含一个名为 `env.d.ts` 的文件,它为你的项目提供 [Vite 的客户端类型](https://cn.vitejs.dev/guide/features.html#client-types):

```typescript title="env.d.ts"
/// <reference types="astro/client" />
/// <reference path="../.astro/types.d.ts" />
```

### TypeScript 编辑器插件
Expand Down
7 changes: 0 additions & 7 deletions src/content/docs/zh-cn/install-and-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,6 @@ Astro 将在一个单独的文件夹(默认为 `dist/`)中构建你的网站
}
```

最后,创建 `src/env.d.ts`,让 TypeScript 知道 Astro 项目中可用的环境类型:

```ts title="src/env.d.ts"
/// <reference types="astro/client" />
```

阅读 Astro 的 [TypeScript 设置指南](/zh-cn/guides/typescript/#设置) 以获取更多信息。

7. 接下来
Expand All @@ -411,7 +405,6 @@ Astro 将在一个单独的文件夹(默认为 `dist/`)中构建你的网站
- src/
- pages/
- index.astro
- env.d.ts
- astro.config.mjs
- package-lock.json 或 `yarn.lock`、`pnpm-lock.yaml` 等。
- package.json
Expand Down
Loading