25 lines
627 B
JavaScript
Raw Normal View History

2021-07-23 16:45:09 +01:00
2021-09-30 11:03:43 -05:00
import getSSRApolloClient from '../api/ssrApollo'
2021-07-23 16:45:09 +01:00
import generateRssFeed from '../lib/rss'
2022-02-17 11:23:43 -06:00
import { ITEMS } from '../fragments/items'
2021-07-23 16:45:09 +01:00
export default function RssFeed () {
return null
}
2021-08-09 14:47:39 -05:00
export async function getServerSideProps ({ req, res }) {
2021-07-23 16:45:09 +01:00
const emptyProps = { props: {} } // to avoid server side warnings
2021-09-30 11:03:43 -05:00
const client = await getSSRApolloClient(req)
2022-02-17 11:23:43 -06:00
const { error, data: { items: { items } } } = await client.query({
query: ITEMS
2021-07-23 16:45:09 +01:00
})
2021-08-09 14:47:39 -05:00
if (!items || error) return emptyProps
2021-07-23 16:45:09 +01:00
2022-01-07 15:29:38 -06:00
res.setHeader('Content-Type', 'text/xml; charset=utf-8')
2021-08-09 14:47:39 -05:00
res.write(generateRssFeed(items))
2021-07-23 16:45:09 +01:00
res.end()
return emptyProps
}