File indexing completed on 2025-01-26 05:27:59
0001 import React, { useState, useEffect } from 'react'; 0002 import Axios from 'axios'; 0003 0004 const BlogFeedContainer = (props) => { 0005 0006 const [items, setItems] = useState([]); 0007 0008 useEffect(() => { 0009 Axios.get(`/json/forum`) 0010 .then(result => { 0011 let topics = result.data.topic_list.topics; 0012 topics.sort(function (a, b) { 0013 return new Date(b.last_posted_at) - new Date(a.last_posted_at); 0014 }); 0015 topics = topics.slice(0, 5); 0016 setItems(topics); 0017 }) 0018 }, []); 0019 0020 return ( 0021 <div className="panelContainer"> 0022 <div className="title"><a href={props.urlCommunity}>Forum</a></div> 0023 <ul> 0024 {items.map((fi, index) => ( 0025 <li key={index}> 0026 <a className="title" href={props.urlCommunity + "/t/" + fi.id}> 0027 <span>{fi.title}</span> 0028 </a> 0029 <span className="info-row"> 0030 <span className="date">{fi.timeago}</span> 0031 <span className="comment-counter">{fi.replyMsg}</span> 0032 </span> 0033 </li> 0034 ) 0035 )} 0036 </ul> 0037 </div> 0038 ) 0039 } 0040 0041 export default BlogFeedContainer 0042 0043