darthmeme / gridsome-plugin-rss

Generate an RSS feed from your Gridsome data store
15 stars 11 forks source link

Sorting Issue #3

Closed danvega closed 5 years ago

danvega commented 5 years ago

Is there a way to sort them? When I import this feed into feedly it shows my very 1st post at the top even though I have a pubDate on each of them.

darthmeme commented 5 years ago

Hi @danvega

The pubDate option is the publication date of the feed (you define it in the feedOptions object). For each individual item, you need to specify a date key inside feedItemOptions.

danvega commented 5 years ago

This is what I have

{
      use: 'gridsome-plugin-rss',
      options: {
        contentTypeName: 'Post',
        feedOptions: {
          title: 'Dan Vega',
          feed_url: 'https://danvega.dev/rss.xml',
          site_url: 'https://danvega.dev'
        },
        feedItemOptions: node => ({
          title: node.title,
          description: node.excerpt,
          url: getPostURL(node.fields.date, node.slug),
          author: node.fields.author,
          date: node.fields.date
        }),
        output: {
          dir: './static',
          name: 'rss.xml'
        }
      }
    },

And this is my feed https://www.danvega.dev/feed

darthmeme commented 5 years ago

Hmm...I'm not sure how Feedly is sorting the items. Other feed readers such as Feeder seem to sort your feed normally.

Since this isn't a bug with the plugin itself, I'm gonna close the issue, but feel free to comment if you find something out!

darthmeme commented 5 years ago

@danvega - I may have found a solution for your feed to sort properly on Feedly, could you add this to feedItemOptions and see if it works?

custom_elements: [
  {
    published: node.fields.date,
  },
]
danvega commented 5 years ago

So I did that and no change.

{
      use: 'gridsome-plugin-rss',
      options: {
        contentTypeName: 'Post',
        feedOptions: {
          title: 'Dan Vega',
          feed_url: 'https://danvega.dev/rss.xml',
          site_url: 'https://danvega.dev'
        },
        feedItemOptions: node => ({
          title: node.title,
          description: node.excerpt,
          url: getPostURL(node.fields.date, node.slug),
          author: node.fields.author,
          date: node.fields.date,
          custom_elements: [{
            published: node.date,
          }, ]
        }),
        output: {
          dir: './static',
          name: 'rss.xml'
        }
      }
    },

Posts are showing up in the same order and because I did this yesterday and the build happened yesterday, it shows all of these posts as 1 day ago.

2019-03-22_06-28-49

darthmeme commented 5 years ago

@danvega - can you change published to node.fields.date instead of node.date. The later seems to be giving a UNIX timestamp instead of a date string.

danvega commented 5 years ago

Same issue.

darthmeme commented 5 years ago

Opened a PR here: https://github.com/danvega/danvega-dev/pull/20

danvega commented 5 years ago

I am so sorry I pushed a commit with your suggestion before I saw the PR. I am still seeing the same issue https://www.danvega.dev/rss.xml

I also see I have a pubDate and published node, should I remove the date from the feedOptions?

<item>
<title>
<![CDATA[ Happy New Year! My 2019 Goals ]]>
</title>
<description>
<![CDATA[ Happy New Year! My 2019 Goals ]]>
</description>
<link>
https://www.danvega.dev/blog/2019/01/01/happy-new-year-my-2019-goals
</link>
<guid isPermaLink="true">
https://www.danvega.dev/blog/2019/01/01/happy-new-year-my-2019-goals
</guid>
<pubDate>Tue, 01 Jan 2019 13:38:10 GMT</pubDate>
<published>Tue Jan 01 2019 13:38:10 GMT+0000 (UTC)</published>
</item>
darthmeme commented 5 years ago

Huh, that's super weird because my PR preview works fine in Feedly

darthmeme commented 5 years ago

Maybe they might be pulling in a previous cached version of the live feed?

darthmeme commented 5 years ago

@danvega Yep, it seems that Feedly caches the RSS, I closed my PR but before that I tested by changing your latest article (excerpt, author & content) and re-pulling the feed into Feedly and it was showing an older version of that article.

One comment I found by googling around is to change the URL of your feed. Maybe try that?

danvega commented 5 years ago

This is fixed, sorry for not closing!