@rspress/plugin-rss
Generates RSS files for selected documentation pages with feed.
Installation
Update Rspress config
By default, this plugin generates a blog.xml file in the doc_build/rss/ folder for all pages starting with /blog/.
The RSS file can be accessed via /rss/blog.xml.
This plugin only works with rspress build and does not generate RSS files on rspress dev.
Usage
Selecting pages to be included in RSS
Use the feed.test option to select which pages are included in the RSS file.
Requirements
All documents included in the RSS must have either date or published_at in frontmatter to keep RSS updates stable for readers.
Generating multiple RSS files
Sometimes you may need to generate multiple RSS files, for example for different languages or categories.
Pass a list of RSS options to feed:
The options above will generate four RSS files: blog.xml, blog-zh.xml, rspack.xml, rsbuild.xml, all located in the rss folder.
Modifying the output path
You can customize the output path using the output and feed.output parameters.
See FeedOutputOptions below.
Linking RSS to doc pages
By default, this plugin inserts a <link rel="alternate"> tag into selected pages included in the RSS. The tag points to the RSS file URL, so RSS readers can detect it automatically.
To insert this tag into pages that are not included in the RSS, such as the homepage, add link-rss frontmatter with the feed ID as the value. For example:
link-rss also supports inserting multiple <link> tags associated with feed ids on a single page:
Customize RSS content
The RSS file consists of two parts: the RSS basic information, known as the channel in the RSS format, and the list of articles, known as the item in the RSS format.
Customize each part as follows:
- The
channelcan be fully modified through thefeedoption. See Other Options below. - The
itemcan be fully modified through thefeed.itemoption. See the item section below.
Options
PluginRssOptions
Plugin options.
siteUrl
- Type:
string - Default:
siteOrigin+base, orbasewhensiteOriginis not configured
The site URL of the current documentation site. It is used in the RSS file.
RSS links are consumed outside the documentation page context, so configure an absolute URL with protocol and domain, such as https://example.com/base/. When base is configured, plugin-level siteUrl must include the base path.
If siteOrigin and base are configured in Rspress, you can omit the plugin-level siteUrl. The full URL concatenation order is siteOrigin + base + routePath. If neither plugin-level siteUrl nor siteOrigin is configured, the plugin falls back to base, which keeps existing relative path behavior but does not generate absolute RSS links.
feed
- Type:
FeedChannel | FeedChannel[] - Default:
{ id: 'blog', test: '/blog/' }
RSS configuration. Pass an array to generate multiple RSS files.
See FeedChannel for more information.
output
- Type:
Omit<FeedOutputOptions, "filename"> - Default:
{ dir: 'rss', type: 'atom' }
Output options. See FeedOutputOptions below.
FeedChannel
RSS file options.
id
- Type:
string - Required
The RSS feed ID, which must be unique across multiple RSS options. It is also the default file basename for the RSS file.
test
- Type:
RegExp | string | (RegExp | string)[] | ((item: PageIndexInfo) => boolean) - Required
Selects documents to include in the RSS. Supported values:
RegExp: Regular expression that matches the document route.string: Prefix-based match against the document route.(item: PageIndexInfo) => boolean: Match pages based on page data and frontmatter. This is also the recommended way to include a route prefix while excluding specific pages such as/blog/.
item.routePath does not include the base path.
For example, if you only want to include article pages under /blog/ but exclude the blog index page itself:
item
- Type:
(item: FeedItem, page: PageIndexInfo, siteUrl: string) => FeedItem | PromiseLike<FeedItem> - Default:
Generates structured data for each article in the RSS file.
Refer to the type of structured data:
The plugin has a built-in generator that uses document frontmatter and page data.
For example, RSS content uses summary from frontmatter first, then falls back to document content.
Provide the item function to modify the generated data passed as the first parameter.
For example, the following configuration truncates the content of articles in the RSS:
output
- Type:
FeedOutputOptions - Default: Uses the plugin's
outputoption by default
Compared with the plugin-level output option, this option also includes filename for changing the output filename.
See FeedOutputOptions below.
Other options
FeedChannel also inherits FeedOptions from the feed package. See
FeedOutputOptions
RSS output options. They are available both at the plugin level and the feed level, with the following type:
Example:
Building with the options above will output two files: feeds/blog.xml and releases/feed.rss.
dir
- Type:
string - Default:
rss
Output folder for RSS files, relative to doc_build.
type
- Type:
"atom" | "rss" | "json" - Default:
atom
RSS output format. The default is atom:
filename
- Type:
string - Default: ID as the file basename; extension by RSS output format
Modifies the full filename of the RSS file.
publicPath
- Type:
string - Default: the value of
siteUrl
URL prefix for the RSS file. An RSS URL is composed of publicPath, dir, and filename.
sorting
- Type:
sorting?: (left: FeedItem, right: FeedItem) => number;
Sorts articles. By default, newest articles appear first.
transform
- Type:
(content: string, context: { type: 'atom' | 'rss' | 'json'; feed: Feed; channel: FeedChannel }) => string | PromiseLike<string>
Transform the final generated feed content before it is written to disk. This hook is available in both the plugin-level output option and the per-feed output option, so the same customization pattern can be used for Atom, RSS, and JSON Feed outputs.
For example, the following configuration injects a custom folo:id into XML feeds and adds the same identifier to JSON Feed: