Skip to content
Merged
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
6 changes: 5 additions & 1 deletion src/content/docs/zh-cn/recipes/rss.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ items: import.meta.glob('./blog/*.{md,mdx}'),

<p><Since v="1.6.14" /></p>

`content` 键包含文章的完整内容作为 HTML。这允许你将整个文章内容提供给 RSS 订阅阅读器。
在 `rss.items` 上设置 `content` 键以提供文章的完整 HTML 内容。这允许 `@astrojs/rss` 将你的文章的完整 Markdown 文本提供给 RSS 阅读器。支持带有完整 URL 路径的图像和链接。但是,不支持使用相对路径的图片和指向其他页面的内部链接。

在渲染完整的文章内容时,你需要考虑图像、相对链接、样式、脚本以及文章中可能包含的超出标准 Markdown 文本的其他元素。 你可能需要在你的 `src/pages/rss.xml.js` 端点中加入额外的逻辑来处理这些元素,或者删除不需要的元素(例如,仅用于样式或网站交互的元素)。

你可以查看[这个具体的社区实现](https://github.com/delucis/astro-blog-full-text-rss/blob/latest/src/pages/rss.xml.ts),它针对这些问题提出了解决方法,作为如何处理的示例。

:::tip
无论何时在 XML 中使用 HTML 内容,我们建议使用像 [`sanitize-html`](https://www.npmjs.com/package/sanitize-html) 这样的包,以确保你的内容被正确地清理、转义和编码。在这个过程中,这样的包可能也会移除一些无害的元素和属性,所以请确保验证输出并根据你的需要配置包。
Expand Down