Skip to content

Provide ability to filter RSS / Atom feed #8376

@johnnyreilly

Description

@johnnyreilly

Have you read the Contributing Guidelines on issues?

Description

My blog turns out to be quite large. It was recently brought to my attention that the RSS feed wasn't working well for readers as a consequence.

At present, Docusaurus includes all blog entries in the Atom / RSS feeds: https://docusaurus.io/docs/blog#feed

The proposal is to add another option to support filtering the responses in the feed. This would allow people to reduce the size of their blogs when they become large.

Has this been requested on Canny?

No

Motivation

see description.

API design

Consider the below type with a new filter option:

type FeedType = 'rss' | 'atom' | 'json';

type BlogOptions = {
  feedOptions?: {
    type?: FeedType | 'all' | FeedType[] | null;
    title?: string;
    description?: string;
    copyright: string;
    language?: string; // possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
    filter?: (blogItem: BlogItem, index: number) => boolean; // **NEW OPTION**
  };
};

This could then be used like this:

module.exports = {
  // ...
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        blog: {
          feedOptions: {
            type: 'all',
            filter: (blogItem, index) => index < 20, // only include first 20 entries
          },
        },
      },
    ],
  ],
};

Have you tried building it?

No - but I would. I've built a workaround in my blog: johnnyreilly/blog.johnnyreilly.com#352

Yes: see #8378

Self-service

  • I'd be willing to contribute this feature to Docusaurus myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions