Skip to content

Commit

Permalink
error handeling for rss
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhouieh committed Jan 29, 2024
1 parent e25677e commit a97fcec
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
19 changes: 10 additions & 9 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: [
'localhost',
'127.0.0.1',
'image.simplecastcdn.com',
'img.youtube.com',
],
},
reactStrictMode: true,
images: {
domains: [
'localhost',
'127.0.0.1',
'image.simplecastcdn.com',
'img.youtube.com',
'strapi.logos.co'
],
},
}

module.exports = nextConfig
12 changes: 8 additions & 4 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ export const getStaticProps: GetStaticProps<PageProps> = async () => {

const { data: tags = [] } = await strapiApi.getTopics()

const rss = new LPERssFeed('main')
await rss.init()
latest.data.forEach((post) => rss.addPost(post))
await rss.save()
try {
const rss = new LPERssFeed('main')
await rss.init()
latest.data.forEach((post) => rss.addPost(post))
await rss.save()
} catch (e) {
console.log('Error generating RSS feed', e)
}

return {
props: {
Expand Down
30 changes: 17 additions & 13 deletions src/pages/podcasts/[showSlug]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,23 @@ export const getStaticProps = async ({ params }: GetStaticPropsContext) => {
showSlug: showSlug as string,
})

const rss = new LPERssFeed(showSlug as string, {
title: shows[0].title,
description: shows[0].descriptionText,
image: shows[0].logo.url,
language: 'en',
id: shows[0].id ?? (showSlug as string),
copyright: `All rights reserved ${new Date().getFullYear()}, ${
shows[0].title
}`,
})
await rss.init()
latestEpisodes.data.forEach((post: LPE.Post.Document) => rss.addPost(post))
await rss.save()
try {
const rss = new LPERssFeed(showSlug as string, {
title: shows[0].title,
description: shows[0].descriptionText,
image: shows[0].logo.url,
language: 'en',
id: shows[0].id ?? (showSlug as string),
copyright: `All rights reserved ${new Date().getFullYear()}, ${
shows[0].title
}`,
})
await rss.init()
latestEpisodes.data.forEach((post: LPE.Post.Document) => rss.addPost(post))
await rss.save()
} catch (e) {
console.log('Error generating RSS feed', e)
}

return {
props: {
Expand Down

0 comments on commit a97fcec

Please sign in to comment.