@@ -49,13 +49,28 @@ export default function RssFeed() {
4949 const chineseRssSources = [
5050 { url : "https://www.oschina.net/news/rss" , title : "开源中国" } ,
5151 {
52- url : "http ://www.ruanyifeng .com/blog/atom.xml " ,
53- title : "阮一峰的网络日志 " ,
52+ url : "https ://www.ithome .com/rss/ " ,
53+ title : "IT之家 " ,
5454 } ,
55- { url : "https://coolshell.cn/feed" , title : "酷壳" } ,
5655 {
57- url : "https://www.zhangxinxu.com/wordpress/feed/" ,
58- title : "张鑫旭的博客" ,
56+ url : "https://sspai.com/feed" ,
57+ title : "少数派" ,
58+ } ,
59+ {
60+ url : "https://www.gcores.com/rss" ,
61+ title : "机核" ,
62+ } ,
63+ {
64+ url : "https://www.solidot.org/index.rss" ,
65+ title : "Solidot" ,
66+ } ,
67+ {
68+ url : "https://feeds.appinn.com/appinns/" ,
69+ title : "Appinn" ,
70+ } ,
71+ {
72+ url : "https://www.geekpark.net/rss" ,
73+ title : "GeekPark" ,
5974 } ,
6075 ] ;
6176
@@ -155,6 +170,8 @@ export default function RssFeed() {
155170 year : "numeric" ,
156171 month : "short" ,
157172 day : "numeric" ,
173+ hour : "2-digit" ,
174+ minute : "2-digit" ,
158175 } ) . format ( date ) ;
159176 } catch ( e ) {
160177 return dateString ;
@@ -184,6 +201,24 @@ export default function RssFeed() {
184201 ) ;
185202 } ;
186203
204+ // 从文章描述中提取第一张图片的URL
205+ const extractImageFromDescription = ( description : string ) : string | null => {
206+ if ( ! description ) return null ;
207+
208+ // 处理CDATA
209+ const content = extractCdata ( description ) ;
210+ // 尝试从HTML中匹配图片
211+ const imgMatch = content . match ( / < i m g [ ^ > ] + s r c = " ( [ ^ " ] + ) " / i) ;
212+ return imgMatch ? imgMatch [ 1 ] : null ;
213+ } ;
214+
215+ // 处理图片加载错误
216+ const handleImageError = (
217+ event : React . SyntheticEvent < HTMLImageElement , Event >
218+ ) => {
219+ event . currentTarget . style . display = "none" ;
220+ } ;
221+
187222 if ( loading ) {
188223 return (
189224 < div className = "w-full mt-6" >
@@ -319,11 +354,24 @@ export default function RssFeed() {
319354 < img
320355 src = { item . thumbnail }
321356 alt = { item . title }
357+ onError = { handleImageError }
322358 className = "w-full h-48 object-cover transform hover:scale-105 transition-transform duration-300"
323359 />
324360 </ div >
325361 ) }
326362
363+ { ! item . thumbnail &&
364+ extractImageFromDescription ( item . description ) && (
365+ < div className = "mb-3 overflow-hidden rounded" >
366+ < img
367+ src = { extractImageFromDescription ( item . description ) ! }
368+ alt = { item . title }
369+ onError = { handleImageError }
370+ className = "w-full h-48 object-cover transform hover:scale-105 transition-transform duration-300"
371+ />
372+ </ div >
373+ ) }
374+
327375 < h3 className = "text-base font-medium text-gray-900 dark:text-white mb-2 line-clamp-2" >
328376 { extractCdata ( item . title ) }
329377 </ h3 >
0 commit comments