Skip to content

Commit

Permalink
i18n(zh-CN): update tutorial pages to match tutorial repo (#4776)
Browse files Browse the repository at this point in the history
Co-authored-by: Elian ☕️ <hello@elian.codes>
  • Loading branch information
Genteure and ElianCodes authored Sep 22, 2023
1 parent d2c3e1d commit 23665db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
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

0 comments on commit 23665db

Please sign in to comment.