Skip to content

Commit

Permalink
i18n(zh-cn): Update rss.mdx (withastro#8006)
Browse files Browse the repository at this point in the history
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
  • Loading branch information
2 people authored and wpplumber committed May 4, 2024
1 parent 3dc142a commit 9628693
Showing 1 changed file with 24 additions and 0 deletions.
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

0 comments on commit 9628693

Please sign in to comment.