+ {frontmatter.pubDate.toString().slice(0,10)}
+ {frontmatter.description}
+ Written by: {frontmatter.author}
+
+ ...
+ ```
+
+### 更新 RSS 函数
+
+14. 最后,教程博客项目包括一个 RSS 提要。该函数必须使用 `getCollection()` 来返回博客文章中的信息。然后,你可以使用返回的 `data` 对象生成 RSS 项。
+
+ ```js title="src/pages/rss.xml.js" del={2,11} ins={3,6,12-17}
+ import rss from '@astrojs/rss';
+ import { pagesGlobToRssItems } from '@astrojs/rss';
+ import { getCollection } from 'astro:content';
+
+ export async function GET(context) {
+ const posts = await getCollection("posts");
+ return rss({
+ title: 'Astro Learner | Blog',
+ description: 'My journey learning Astro',
+ site: context.site,
+ items: await pagesGlobToRssItems(import.meta.glob('./**/*.md')),
+ items: posts.map((post) => ({
+ title: post.data.title,
+ pubDate: post.data.pubDate,
+ description: post.data.description,
+ link: `/posts/${post.slug}/`,
+ })),
+ customData: `en-us`,
+ })
+ }
+ ```
+
+要查看使用内容集合的博客教程的完整示例,请访问教程存储库的 [Content Collections 分支](https://github.com/withastro/blog-tutorial-demo/tree/content-collections)。