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 tutorial pages to match tutorial repo #4776

Merged
merged 2 commits into from
Sep 22, 2023
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
22 changes: 16 additions & 6 deletions src/content/docs/zh-cn/tutorial/5-astro-api/4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,33 @@ Astro 提供了一个可自定义包,用于快速为你的网站添加一个 R

1. 在 `src/pages/` 目录下创建一个名为 `rss.xml.js` 的新文件。

2. 将以下代码复制到这个新文档中,并将 `site` 属性替换为你的网站自己的唯一 Netlify URL。自定义 `title` 和 `description` 属性,如果需要,可以在 `customData` 中指定不同的语言:
2. 将以下代码复制到这个新文档中。自定义 `title` 和 `description` 属性,如果需要,可以在 `customData` 中指定不同的语言:

```js title="src/pages/rss.xml.js"
import rss, { pagesGlobToRssItems } from '@astrojs/rss';

export async function GET() {
export async function GET(context) {
return rss({
title: 'Astro Learner | Blog',
description: 'My journey learning Astro',
site: 'https://my-blog-site.netlify.app',
site: context.site,
items: await pagesGlobToRssItems(import.meta.glob('./**/*.md')),
customData: `<language>en-us</language>`,
});
}
```

3. 这个 `rss.xml` 文档只有在编译你的网站时才会创建,因此在开发过程中无法在浏览器中查看该页面。退出开发服务器,并运行以下命令,首先在本地编译你的网站,然后查看编译的预览:
3. 在 Astro 的配置文件中设置 `site` 属性为你的网站自己的唯一 Netlify URL。

```js title="astro.config.mjs" ins={4}
import { defineConfig } from "astro/config";

export default defineConfig({
site: "https://example.com"
});
```

4. 这个 `rss.xml` 文档只有在构建你的网站时才会创建,因此在开发过程中无法在浏览器中查看该页面。退出开发服务器,并运行以下命令,首先在本地编译你的网站,然后查看编译的预览:

<PackageManagerTabs>
<Fragment slot="npm">
Expand All @@ -109,13 +119,13 @@ Astro 提供了一个可自定义包,用于快速为你的网站添加一个 R
</Fragment>
</PackageManagerTabs>

4. 访问 `http://localhost:4321/rss.xml`,验证你是否可以在页面上看到(未格式化的)文本,每个 `.md` 文件都有一个 `item`。每个 `item` 应包含博客文章的信息,例如 `title`、`url` 和 `description`。
5. 访问 `http://localhost:4321/rss.xml`,验证你是否可以在页面上看到(未格式化的)文本,每个 `.md` 文件都有一个 `item`。每个 `item` 应包含博客文章的信息,例如 `title`、`url` 和 `description`。

:::tip[在阅读器中查看你的 RSS 订阅源]
下载一个订阅源阅读器,或者注册一个在线订阅源阅读器服务,并通过添加你自己的 Netlify URL 订阅你的网站。你也可以将此链接分享给他人,让他们订阅你的文章,并在发布新文章时收到通知。
:::

5. 当你想以开发模式查看你的网站时,请确保退出预览并重新启动开发服务器。
6. 当你想以开发模式查看你的网站时,请确保退出预览并重新启动开发服务器。

<Box icon="check-list">

Expand Down
1 change: 0 additions & 1 deletion src/content/docs/zh-cn/tutorial/6-islands/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import PreCheck from '~/components/tutorial/PreCheck.astro';
2. 将以下代码添加到 `Greeting.jsx` 文件中:

```jsx title="src/components/Greeting.jsx"
import { h } from 'preact';
import { useState } from 'preact/hooks';

export default function Greeting({messages}) {
Expand Down