diff --git a/.vscode/launch.json b/.vscode/launch.json index 9d69714..00940c7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,8 +10,14 @@ "run", "dev" ], - "port": 3000, // Default port for Vite development server "console": "integratedTerminal", + "env": { + "NO_COLOR": "1" + }, + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bhttp://localhost:([0-9]+)\\b", + } } ] } \ No newline at end of file diff --git a/src/pages/Index.jsx b/src/pages/Index.jsx index 1c48c90..40e8962 100644 --- a/src/pages/Index.jsx +++ b/src/pages/Index.jsx @@ -26,8 +26,8 @@ const Index = () => { }, []); useEffect(() => { - const fetchRSSItems = async () => {; - + const fetchRSSItems = async () => { + const proxyUrl = 'https://corsproxy.io/?url='; const counts = {}; let totalItems = 0; const uniqueItems = new Map(); @@ -36,8 +36,7 @@ const Index = () => { try { let response; if (feed.cors) { - // Todo: Use a proxy to avoid CORS issues - continue; + response = await fetch(proxyUrl + encodeURIComponent(feed.url)).then(res => res.text()); } else { response = await fetch(feed.url).then(res => res.text()); } @@ -67,7 +66,9 @@ const Index = () => { } } - uniqueItems.forEach((value, title) => { + const sortedItems = Array.from(uniqueItems.entries()).sort((a, b) => new Date(b[1].pubDate) - new Date(a[1].pubDate)); + + sortedItems.forEach(([title, value]) => { const newsItem = document.createElement('div'); newsItem.className = 'news-item'; newsItem.innerHTML = ` @@ -148,8 +149,7 @@ const Index = () => {