gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.27k stars 10.31k forks source link

Untitled RSS Feed when using setup function #16018

Closed PaulBadeuille closed 5 years ago

PaulBadeuille commented 5 years ago

Description

As explained in docs, when I want to add custom_elements with setup function in RSS feeds with gatsby-plugin-feed, my RSS title, description and link become "Untitled RSS Feed". When I don't use custom_elements and custom setup, I have the right title.

Steps to reproduce

Just use custom setup function as explained here https://www.gatsbyjs.org/docs/adding-an-rss-feed/

Expected result

Title, description and link should are correct.

Actual result

<title><![CDATA[Untitled RSS Feed]]></title><description><![CDATA[Untitled RSS Feed]]></description><link>http://github.com/dylang/node-rss</link>

Environment

System:
    OS: Windows 10
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
Languages:
    Python: 2.7.15
Browsers:
    Edge: 44.18932.1000.0
npmPackages:
    gatsby: ^2.4.0 => 2.4.0
    gatsby-cli: ^2.6.5 => 2.6.5
    gatsby-image: ^2.0.27 => 2.0.27
    gatsby-plugin-favicon: ^3.1.5 => 3.1.5
    gatsby-plugin-feed: ^2.3.4 => 2.3.4
    gatsby-plugin-google-tagmanager: ^2.0.8 => 2.0.8
    gatsby-plugin-react-helmet: ^3.0.5 => 3.0.5
    gatsby-plugin-robots-txt: ^1.3.0 => 1.3.0
    gatsby-plugin-sharp: ^2.0.18 => 2.0.18
    gatsby-plugin-sitemap: ^2.0.4 => 2.0.4
    gatsby-plugin-zopfli: ^1.0.2 => 1.0.2
    gatsby-remark-emojis: ^0.2.3 => 0.2.3
    gatsby-remark-images: ^3.0.1 => 3.0.1
    gatsby-source-airtable: ^2.0.3 => 2.0.3
    gatsby-source-filesystem: ^2.0.17 => 2.0.17
    gatsby-transformer-remark: ^2.2.0 => 2.2.0
    gatsby-transformer-sharp: ^2.1.12 => 2.1.12
gatsbot[bot] commented 5 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

gatsbot[bot] commented 5 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community!

abuuzayr commented 4 years ago

I can confirm this is happening, as @Boogy62 described: Adding a setup method for gatsby-plugin-feed options in gatsby-config would 'reset' the following fields:

Screenshot 2020-01-26 at 7 22 58 PM

You can also return an empty object for the setup method like so to get the same results:

...
setup: () => ({}),
...

So I suppose we have two options:

1. Shift all our options into the setup method like so:

...
        setup: () => ({
          title: 'Title of your site or feed',
          description: 'A short description of the feed.',
          generator: 'Feed generator.',
          feed_url: 'Url to the rss feed.',
          site_url: 'Url to the site that the feed is for.',
          image_url: 'Small image for feed readers to use.',
          docs: 'Url to documentation on this feed.',
          managingEditor: 'Who manages content in this feed.',
          webMaster: 'Who manages feed availability and technical support.',
          copyright: 'Copyright information for this feed.',
          language: 'The language of the content of this feed.',
          categories: [],
          pubDate: 'The publication date for content in the feed',
          ttl: 'Number of minutes feed can be cached before refreshing from source.',
          hub: 'hub url Where is the PubSubHub hub located.',
          custom_namespaces: {},
          custom_elements: [],
        }),
...

The above options are from https://www.npmjs.com/package/rss#feedoptions

This means we have to update the documentation to inform users that if they wish to use the setup method it will override all other options, whether or not they are explicitly set (the generator tag is set by the plugin automatically, but reset when setup is used).

2. Fix the plugin to not override the affected fields if they are not set in the setup method:

Which one of these is preferred by the Gatsby team?


While it is being decided, if someone comes across this issue, please use the first option as a workaround if you need to use custom_namespaces or custom_elements.

leafac commented 4 years ago

A better solution: Pass along the options received by setup:

setup: options => ({
  custom_namespaces: {},
  custom_elements: [],
  ...options
})

Source