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

[gatsby-plugin-feed] Api for creating multiple dynamic feeds based off of a query #12184

Closed
jsanchez034 opened this issue Feb 28, 2019 · 11 comments

Comments

@jsanchez034
Copy link

jsanchez034 commented Feb 28, 2019

Summary

When creating rss feeds with gatsby-plugin-feed it would be great to have the ability to create multiple feeds from dynamic data coming from a single GraphQL query. In other words to create numerous feeds at build time where you wouldn't know up front ( without GraphQL query data ) how many you need.

Basic example

Bellow I'm proposing adding a new config property to a feed object called mapToFeedFiles. From it the user would return an array of feed objects that would support all current feed properties minus serialize and instead support a property called serializedItems which basically would be similar to what serialize property function normally would return.

{
  resolve : 'gatsby-plugin-feed',
  options : {
    query : `
      {
        site {
          siteMetadata {
            title
            description
            site_url
          }
        }
      }
    `,
    feeds : [
      {
        query : `{
          allBlogCategory {
            edges {
              node {
                name
                fields {
                  categorySlug
                }
                blog___post {
                  title
                  publishedOn
                  author {
                    name
                  }
                  body {
                    html
                  }
                  fields {
                    postSlug
                  }
                }
              }
            }
          }
        }`,
        mapToFeedFiles : ({ query: { site, allContentfulBlogCategory } }) => {
          return allContentfulBlogCategory.edges.map(({ node }) => {
            const { name, fields, blog___post : categoryBlogPosts } = node;
            return {
              title             : name,
              output            : `/category/${fields.categorySlug}/rss.xml`,
              serializedItems   : categoryBlogPosts.map(() => mapPostToRSSFeedItem(node))
            };
          });
        }
      }
    ]
  }
}

Motivation

The motivation behind this is say you have a blog with posts that each have a main category assigned to them. Furthermore the categories are created by content creators in your headless CMS system such a Contentful. Each category has its own page on your blog site listing the posts under that category and you want each page to have a rss feed. The above api addition would allow for creating a rss feed per category.

If given the ok with the above api from the maintainers of the plugin, I can implement the new feature as well. I just wanted some feedback on the proposal before creating a PR. Thanks for the consideration!

@jsanchez034
Copy link
Author

Hello @mikefowler and @secretfader I see you guys have contributed to gatsby-plugin-feed. I also see there was a similar proposal earlier in issue #3489. I would love to get some feedback on this new proposal.

@secretfader
Copy link

secretfader commented Mar 6, 2019

While I love seeing people take an interest in RSS (and syndication feeds in general), I've largely stepped away from Gatsby development and no longer have a controlling interest in gatsby-plugin-feed. That said, cases like yours (@jsanchez034) are something I always wanted support for, but proved difficult to execute against.

@DSchau has proposed a few changes to how options are parsed and validated in #12085, which may open the door to supporting new methods for ingesting configuration and creating feeds. Still, the general trend (at least among plugins in the core repo) seems to bend towards the most common use cases, expanding functionality carefully if needed.

It's probably worth considering what it would take to write this feature once the PR covering option validation lands. But it could also be better addressed by a plugin you write to handle a specific use case.

@DSchau
Copy link
Contributor

DSchau commented Mar 6, 2019

@secretfader couldn't have said it better myself.

The work I'm doing in that PR does make it slightly easier to add new features (in a way that the user is at least aware if they're being used incorrectly, wrong options passed).

@jsanchez034 However - this seems like it could lead to some fairly significant bloat in a plugin that is already sorta confusing to use.

I don't ever want to discourage someone from contributing, because I completely understand the use case for the plugin you describe, but maybe this makes most sense as a fork or something that is maintained outside of the Gatsby repo?

In some sense, maintaining a repository is about making sure you're focusing on the right things and balancing the right trade offs. Introducing features that may not be generally applicable (but valuable!) introduce a maintenance burden on maintainers.

What do you think @jsanchez034? Want to make it clear that this is a discussion not a decision. Happy to be persuaded!

@jsanchez034
Copy link
Author

Thanks for the feedback @DSchau and @secretfader! Yeah I think the use case might be too specific like you guys described. I will create a separate plugin for my use case.

@DSchau
Copy link
Contributor

DSchau commented Mar 8, 2019

@jsanchez034 awesome - would you mind keeping us in the loop as to when you publish? We're also happy to provide any feedback along the way!

@jsanchez034
Copy link
Author

Awesome will do 👍 Thanks for the support!

@cedricdelpoux
Copy link

@jsanchez034 Did you publish your plugin? I can't find it

@jsanchez034
Copy link
Author

@jsanchez034 Did you publish your plugin? I can't find it

Hi! Never got around to making the plugin. I ended up not needing the multi feed feature

@cedricdelpoux
Copy link

Ok thank you for your feedback.

@codefull
Copy link

codefull commented Oct 6, 2020

@jsanchez034 Did you publish your plugin? I can't find it

Hi! Never got around to making the plugin. I ended up not needing the multi feed feature

Hi! Did you just dropped multifeed feature or did you just workaround a solution. Please could you let me know, I'm in the same scenario.

@jsanchez034
Copy link
Author

jsanchez034 commented Oct 9, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants