Skip to content

i18n(zh-cn): Update cms/ & routing.mdx #11526

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

Merged
merged 4 commits into from
May 5, 2025
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
2 changes: 1 addition & 1 deletion src/content/docs/zh-cn/guides/cms/preprcms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export async function Prepr(query, variables) {

#### 创建独立的博客文章页面

为了为每篇博客文章创建一个页面,你将在一个使用[动态路由](/zh-cn/guides/routing/#服务器ssr模式)的 `.astro` 页面上执行一个新的 GraphQL 查询。这个查询将通过其 slug 获取一个特定的文章,并为每篇独立的博客文章创建一个新页面。
为了为每篇博客文章创建一个页面,你将在一个使用[动态路由](/zh-cn/guides/routing/#按需动态路由)的 `.astro` 页面上执行一个新的 GraphQL 查询。这个查询将通过其 slug 获取一个特定的文章,并为每篇独立的博客文章创建一个新页面。

<Steps>
1. 在 `queries` 文件夹中创建一个名为 `get-article-by-slug.js` 的文件,并添加以下内容来查询一个特定文章的 slug,并返回诸如文章的 `title` 和 `content` 等数据:
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/zh-cn/guides/cms/strapi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ const article = Astro.props;

#### 按需渲染

如果你选择了 [使用适配器按需渲染](/zh-cn/guides/on-demand-rendering/) ,那么可以使用以下代码来生成你的[动态路由](/zh-cn/guides/routing/#服务器ssr模式)。
如果你选择了 [使用适配器按需渲染](/zh-cn/guides/on-demand-rendering/) ,那么可以使用以下代码来生成你的[动态路由](/zh-cn/guides/routing/#按需动态路由)。

创建 `src/pages/blog/[slug].astro` 文件:

Expand Down
5 changes: 3 additions & 2 deletions src/content/docs/zh-cn/guides/routing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,15 @@ const { title, text } = Astro.props;
</html>
```

### 服务器(SSR)模式
### 按需动态路由

在 [SSR](/zh-cn/guides/on-demand-rendering/) 模式下,动态路由以相同的方式定义:在文件名中包含 `[param]` 或 `[...path]` 以匹配任意字符串或路径。但是由于不再提前构建路由,页面将提供给任何匹配的路由。由于这些路由不是“静态”的,因此不应使用 `getStaticPaths`。
对于使用适配器进行 [按需渲染](/zh-cn/guides/on-demand-rendering/) 的情况下,动态路由以相同的方式定义:在文件名中包含 `[param]` 或 `[...path]` 以匹配任意字符串或路径。但是由于不再提前构建路由,页面将提供给任何匹配的路由。由于这些路由不是“静态”的,因此不应使用 `getStaticPaths`。

对于按需渲染路由,文件名中应该只使用一次对剩余参数的展开语法(例如应该使用 `src/pages/[locale]/[...slug].astro` 或 `src/pages/[...locale]/[slug].astro`,而不是 `src/pages/[...locale]/[...slug].astro`)

```astro title="src/pages/resources/[resource]/[id].astro"
---
export const prerender = false; // 'server' 模式下,无需配置
const { resource, id } = Astro.params;
---
<h1>{resource}: {id}</h1>
Expand Down