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
user T
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.io – build remarkable experiences at scale

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

Related topics

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
How to deploy Gatsby sites using official Sanity starter templates25Nov 30, 2020
How to make Algolia work with Gatsby & Sanity8Jan 7, 2021
How to improve image loading with Gatsby and gatsby-plugin-sanity-image?10Nov 27, 2020
Set up Draft Previews with Gatsby Cloud Hosting4Aug 26, 2020
How to display Sanity images in Gatsby-powered photography sites19Jun 16, 2020
Is it possible to use gatsby-image to render images loaded in Portable Text / Rich Text?8Jan 1, 2021

Related contributions

Occo
- Made with Sanity

Complex product offering with nested product structure and tiered pricing.

Kevin Green
Go to Occo

Figma Config
- Made with Sanity

Website for Config, the global design conference by Figma.

Corey Ward
Go to Figma Config

The Agnes
- Made with Sanity

A high end rental real estate site built with Gatsby, Sanity and Shopify that pulls in listing data via API and includes a headless Shopify shop.

David Gross
Go to The Agnes