From a97fcecf89e64e80f69623827a8063473bbb845d Mon Sep 17 00:00:00 2001 From: amirhouieh Date: Mon, 29 Jan 2024 13:39:35 +0000 Subject: [PATCH] error handeling for rss --- next.config.js | 19 ++++++++-------- src/pages/index.tsx | 12 ++++++---- src/pages/podcasts/[showSlug]/index.tsx | 30 ++++++++++++++----------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/next.config.js b/next.config.js index 743b7a52..811edb87 100644 --- a/next.config.js +++ b/next.config.js @@ -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 diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 577f49a6..5fe8fa47 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -43,10 +43,14 @@ export const getStaticProps: GetStaticProps = 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: { diff --git a/src/pages/podcasts/[showSlug]/index.tsx b/src/pages/podcasts/[showSlug]/index.tsx index fcd42a4f..b6079814 100644 --- a/src/pages/podcasts/[showSlug]/index.tsx +++ b/src/pages/podcasts/[showSlug]/index.tsx @@ -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: {