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 rss.mdx #8006

Merged
merged 2 commits into from Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/content/docs/zh-cn/guides/rss.mdx
Expand Up @@ -214,6 +214,30 @@ export function GET(context) {
}
```

## 移除尾部斜杠

Astro 的 RSS 摘要默认生成带尾部斜杠的链接,无论你为 `trailingSlash` 配置了什么值。这意味着你的 RSS 链接可能与你的文章 url 不完全匹配。

如果你在 `astro.config.mjs` 中设置了 `trailingSlash: "never"`,请在 `rss()` 助手中设置 `trailingSlash: false`,以使你的摘要与项目配置相匹配。

```ts title="src/pages/rss.xml.js" ins={9}
import rss from '@astrojs/rss';

export function GET(context) {
const posts = Object.values(postImportResult);
return rss({
title: 'Buzz 的博客',
description: '一个谦逊的星际旅行宇航员向导',
site: context.site,
trailingSlash: false,
items: posts.map((post) => ({
link: post.url,
...post.frontmatter,
})),
});
}
```

## 添加样式表

你可以为 RSS 摘要添加样式表,以便在浏览器中查看文件时获得更好的用户体验。
Expand Down