Skip to content

Commit

Permalink
i18n(zh-cn): Update v5.mdx (#10788)
Browse files Browse the repository at this point in the history
* i18n(zh-cn): Update `v5.mdx`

* Update v5.mdx

---------

Co-authored-by: Yan <[email protected]>
  • Loading branch information
Nin3lee and yanthomasdev authored Jan 29, 2025
1 parent 2a80481 commit 584d89c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/content/docs/zh-cn/guides/upgrade-to/v5.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,22 @@ Astro 5.0 引入了一个采用 Content Layer API 的新版内容集合,它带
});
```

3. **将引用的 `slug` 更改为 `id`**。Content layer 集合不再保留 `slug` 字段。相反的,所有更新后的集合将会有一个 `id`你可能还需要更新动态路由的文件名,以匹配更新后的 getStaticPaths() 参数:
3. **将引用的 `slug` 更改为 `id`**。Content layer 集合不再保留 `slug` 字段。取而代之的是,所有更新后的集合将会有一个 `id`

```astro ins={7} del={6}
// src/pages/[id].astro
// src/pages/[slug].astro
---
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts.map((post) => ({
params: { slug: post.slug },
params: { id: post.id },
params: { slug: post.id },
props: post,
}));
}
---
```
你可能还需要更新动态路由的文件名,以匹配更新后的 `getStaticPaths()` 参数的值。

4. **切换到新的 `render()` 函数**。条目不再具有 `render()` 方法,因为他们现在是可序列化的简单对象。相反的,应该从 `astro:content` 导入 `render()` 函数。

Expand Down

0 comments on commit 584d89c

Please sign in to comment.