Skip to content

Commit

Permalink
Update docs for withastro/astro#9610 (#6154)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
2 people authored and ematipico committed Jan 26, 2024
1 parent bf5819e commit aa693a0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/content/docs/en/guides/rss.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,20 @@ The package [`@astrojs/rss`](https://github.com/withastro/astro/tree/main/packag

## Generating `items`

The `items` field accepts a list of RSS feed objects, each with a required `link`, `title`, and `pubDate`. Three optional values may also be included `description` (a short excerpt), `content` (the full content of your post), and a `customData` field for including any extra data, such as other frontmatter properties from your blog posts.
The `items` field accepts a list of RSS feed objects, which can be generated from content collections entries using `getCollection()` or from your page files using `pagesGlobToRssItems()`.

You can generate this array from a content collection schema or by using [glob imports](/en/guides/imports/#astroglob) for blog posts located within `src/pages/`.
The RSS feed standard format includes the following values for each published item:

- `title`: The title of the entry. Optional only if a `description` is set. Otherwise, required.
- `description`: A short excerpt from or describing the entry. Optional only if a `title` is set. Otherwise, required.
- `link`: A URL to the original source of the entry. (optional)
- `pubDate`: The date of publication of the entry. (optional)
- `content`: The full content of your post. (optional)
- `customData`: A field for including any extra data, such as other frontmatter properties from your blog posts.

### Using content collections

To create an RSS feed of pages managed in [content collections](/en/guides/content-collections/), use the `getCollection()` function to retrieve the list of your items.
To create an RSS feed of pages managed in [content collections](/en/guides/content-collections/), use the `getCollection()` function to retrieve the data required for your `items` array. You will need to specify the values for each desired property (e.g. `title`, `description`) from the returned data.


```js title="src/pages/rss.xml.js" "items:" "const blog = await getCollection('blog');"
Expand Down Expand Up @@ -145,6 +151,8 @@ In versions of `@astrojs/rss` before v2.1.0, pass your glob result straight to `
```js
items: import.meta.glob('./blog/*.{md,mdx}'),
```

This method is deprecated for all versions of Astro since v2.1.0, and cannot be used on modern projects.
:::

### Including full post content
Expand Down

0 comments on commit aa693a0

Please sign in to comment.