Watch a live product demo 👀 See how Sanity powers richer commerce experiences

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– build remarkable experiences at scale

The Sanity Composable Content Cloud is the 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.

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 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