Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ability to filter RSS / Atom feed #8376

Closed
2 tasks done
johnnyreilly opened this issue Nov 25, 2022 · 4 comments · Fixed by #8378
Closed
2 tasks done

Provide ability to filter RSS / Atom feed #8376

johnnyreilly opened this issue Nov 25, 2022 · 4 comments · Fixed by #8378
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@johnnyreilly
Copy link
Contributor

johnnyreilly commented Nov 25, 2022

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.
@johnnyreilly johnnyreilly added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. status: needs triage This issue has not been triaged by maintainers labels Nov 25, 2022
@Josh-Cena
Copy link
Collaborator

These kinds of callback-based APIs are hard to design properly, but I agree with the motivation. Waiting for more ideas from @slorber. I'm wondering: how do other sites handle this? Do they truncate their feeds to the nearest x entries?

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Dec 3, 2022
@johnnyreilly
Copy link
Contributor Author

From generally looking around there seems to be a latest X entries approach as well as a "paging" approach. Though, from what I've read the paging approach is not well supported.

The approach I've suggested is a filter - I think a reduce could also work here to allow folk to mutate the contents in some way too. (Technically you could do that in a filter but it's not considered good practice from an FP perspective)

I've an idea to drive filtering based on the last git commit in a similar fashion to what I do here:

https://blog.johnnyreilly.com/2022/11/25/adding-lastmod-to-sitemap-git-commit-date

Might be nice to update the Atom / RSS feeds based on this too

@slorber
Copy link
Collaborator

slorber commented Dec 9, 2022

Did some googling and what I understand=

  • our feed can be quite heavy as we include the HTML content
  • Atom can support pagination but RSS can't
  • readers support an arbitrary number of items/feed size, probably hard to find the lowest common denominator
  • Read on a Feedly forum their feed limit is around 8mb

That seems reasonable to add such a feature to me 👍

@johnnyreilly
Copy link
Contributor Author

Resolved by #8378

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants