Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

How to generate RSS.xml files from Sanity posts with gatsby-plugin-feed

5 replies
Last updated: Jan 12, 2021
hey all, is it possible to combine
allSanityPost
and
allMdx
for
gatsby-plugin-feed
and spits out both content on
rss.xml
? Have anyone managed to figure that out? Google only return
user Y
gist and I have used them as reference but only managed to create 2 separate feeds for both MDX and Sanity instead of combining them both into one: https://github.com/ajmalafif/afif.dev/pull/46
Jan 10, 2021, 4:16 PM
hi Ajmal, are you trying to combine the results of
allSanityPost
and
allMdx
into a single feed? So there will be 1 item in the feed for each
mdx
and 1 item for each
sanityPost
, correct?
Jan 12, 2021, 5:58 AM
If that's what you're after you should be able to do something like this:

https://gist.github.com/dylanjha/d92e491f867a41f75df13501d835f51b/revisions
Notice that in that most recent commit I refactored what you had so that
serialize()
returns a single array (
records
).
We iterate through
allSanityPost
and add each one to the
records
array. Then iterate through
allMdx
and do the same. After all of that we return the single
records
array
Jan 12, 2021, 6:06 AM
hey
Dylan Jhaveri
thanks so much!
Yes that is exactly what I wanted to make and it works now
Jan 12, 2021, 9:29 AM
i messed up the mdx part so im posting the one im using in the codebase (the gist one wasnt updated) on top of your help if thats okay
Jan 12, 2021, 9:30 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?