import { Box, Link, Chip, List, ListItem, ListItemText } from '@mui/material'; import { OpenInNew, Comment, TrendingUp } from '@mui/icons-material'; import GenericWidget from './GenericWidget'; function NewsWidget({ data, sx }) { if (!data || data.error) { return (

{data?.message || 'News data unavailable'}

); } // Handle Reddit data if (data.type === 'reddit' && data.posts) { const subreddit = data.url?.match(/\/r\/([^\/\.]+)/)?.[1] || 'Reddit'; return ( {data.posts.slice(0, 5).map((post, index) => ( {post.thumbnail && post.thumbnail.startsWith('http') && ( )}
{post.title}
} secondaryTypographyProps={{ component: 'div' }} secondary={ } label={post.score} size="small" variant="outlined" /> } label={post.comments} size="small" variant="outlined" /> by {post.author} } />
))}
); } // Handle RSS feed data if (data.type === 'rss' && data.items) { return ( {data.items.slice(0, 5).map((item, index) => ( {(item.thumbnail || item.enclosure?.url || item['media:thumbnail']?.url) && ( )}
{item.title}
} secondaryTypographyProps={{ component: 'div' }} secondary={
{item.pubDate && new Date(item.pubDate).toLocaleDateString()}
{item.description && (
{item.description.replace(/<[^>]*>?/gm, '')}
)}
} />
))}
); } // Handle Hacker News data if (data.type === 'hackernews' && data.storyIds) { return (

{data.storyIds.length} top stories loaded

(Story details will load when API is configured)

); } // Default fallback for unknown data types return (

Data format not recognized

{JSON.stringify(data).substring(0, 100)}...

); } export default NewsWidget;