Skip to content

Commit

Permalink
Update rss.mdx (#7878)
Browse files Browse the repository at this point in the history
Co-authored-by: Luiz Ferraz <luiz@lferraz.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
3 people committed Apr 24, 2024
1 parent d2b0509 commit 0d6725c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/content/docs/en/guides/rss.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,30 @@ export function GET(context) {
}
```

## Removing trailing slashes

Astro's RSS feed produces links with a trailing slash by default, no matter what value you have configured for `trailingSlash`. This means that your RSS links may not match your post URLs exactly.

If you have set `trailingSlash: "never"` on your `astro.config.mjs`, set `trailingSlash: false` in the `rss()` helper so that your feed matches your project configuration.

```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’s Blog',
description: 'A humble Astronaut’s guide to the stars',
site: context.site,
trailingSlash: false,
items: posts.map((post) => ({
link: post.url,
...post.frontmatter,
})),
});
}
```

## Adding a stylesheet

Style your RSS feed for a more pleasant user experience when viewing the file in your browser.
Expand Down

0 comments on commit 0d6725c

Please sign in to comment.