fix: news not loading

This commit is contained in:
SethBurkart123
2025-04-09 14:46:57 +10:00
parent 0c1a71f398
commit 56dabc8fd5
2 changed files with 17 additions and 11 deletions
+1
View File
@@ -81,6 +81,7 @@
"dompurify": "^3.2.4", "dompurify": "^3.2.4",
"embla-carousel-autoplay": "^8.5.2", "embla-carousel-autoplay": "^8.5.2",
"embla-carousel-svelte": "^8.5.2", "embla-carousel-svelte": "^8.5.2",
"events": "^3.3.0",
"flexsearch": "^0.8.147", "flexsearch": "^0.8.147",
"fuse.js": "^7.1.0", "fuse.js": "^7.1.0",
"idb": "^8.0.2", "idb": "^8.0.2",
+16 -11
View File
@@ -19,20 +19,25 @@ const rssFeedsByCountry: Record<string, string[]> = {
"https://www.npr.org/rss/rss.php", "https://www.npr.org/rss/rss.php",
], ],
taiwan: [ taiwan: [
"https://focustaiwan.tw/rss", "https://news.ltn.com.tw/rss/all.xml",
"https://www.taipeitimes.com/rss/all.xml", "https://www.taipeitimes.com/xml/index.rss",
"https://international.thenewslens.com/rss", "https://international.thenewslens.com/rss",
], ],
hong_kong: [ hong_kong: [
"https://news.rthk.hk/rthk/en/rss.htm", "https://rthk9.rthk.hk/rthk/news/rss/e_expressnews_elocal.xml",
"https://www.scmp.com/rss/91/feed", "https://www.scmp.com/rss/91/feed",
], ],
panama: [ panama: [
"http://www.panama-guide.com/backend.php", "https://critica.com.pa/rss.xml",
"https://www.panamaamerica.com.pa/rss.xml",
"https://noticiassin.com/feed/",
"https://elcapitalfinanciero.com/feed/"
], ],
canada: [ canada: [
"https://www.cbc.ca/cmlink/rss-topstories", "https://www.cbc.ca/cmlink/rss-topstories",
"https://www.theglobeandmail.com/?service=rss", "https://calgaryherald.com/feed",
"https://ottawacitizen.com/feed",
"https://www.montrealgazette.com/feed"
], ],
singapore: [ singapore: [
"https://www.straitstimes.com/news/singapore/rss.xml", "https://www.straitstimes.com/news/singapore/rss.xml",
@@ -43,20 +48,16 @@ const rssFeedsByCountry: Record<string, string[]> = {
"https://www.theguardian.com/uk/rss", "https://www.theguardian.com/uk/rss",
], ],
japan: [ japan: [
"https://www.japantimes.co.jp/feed/topstories.xml",
"https://www3.nhk.or.jp/nhkworld/en/news/feeds/", "https://www3.nhk.or.jp/nhkworld/en/news/feeds/",
"https://news.livedoor.com/topics/rss/int.xml"
], ],
netherlands: [ netherlands: [
"https://www.dutchnews.nl/feed/", "https://www.dutchnews.nl/feed/",
"http://feeds.nos.nl/nosnieuwsalgemeen", "https://www.nrc.nl/rss/"
], ],
}; };
export async function fetchNews(source: string, sendResponse: any) { export async function fetchNews(source: string, sendResponse: any) {
const parser = new Parser();
let feeds: string[];
console.log('fetchNews', source)
if (source === "australia") { if (source === "australia") {
const date = new Date(); const date = new Date();
@@ -73,6 +74,10 @@ export async function fetchNews(source: string, sendResponse: any) {
return; return;
} }
const parser = new Parser();
let feeds: string[];
console.log('fetchNews', source)
if (rssFeedsByCountry[source.toLowerCase()]) { if (rssFeedsByCountry[source.toLowerCase()]) {
// If the source is a country, fetch from predefined feeds // If the source is a country, fetch from predefined feeds
feeds = rssFeedsByCountry[source.toLowerCase()]; feeds = rssFeedsByCountry[source.toLowerCase()];