/* eslint-disable camelcase */ /* eslint-disable react/no-danger */ import React, { useState, useEffect, FC } from 'react'; import { Collapse, Typography, Skeleton } from 'antd'; import format from 'date-fns/format'; import { fetchExternalData } from '../../utils/apis'; const { Panel } = Collapse; const { Title, Link } = Typography; const OWNCAST_FEED_URL = 'https://owncast.online/news/index.json'; const OWNCAST_BASE_URL = 'https://owncast.online'; export type ArticleProps = { title: string; url: string; content_html: string; date_published: string; }; const ArticleItem: FC = ({ title, url, content_html: content, date_published: date, }) => { const dateObject = new Date(date); const dateString = format(dateObject, 'MMM dd, yyyy, HH:mm'); return (

{dateString} ( Link )

); }; export const NewsFeed = () => { const [feed, setFeed] = useState([]); const [loading, setLoading] = useState(true); const getFeed = async () => { setLoading(false); try { const result = await fetchExternalData(OWNCAST_FEED_URL); if (result?.items.length > 0) { setFeed(result.items); } } catch (error) { console.log('==== error', error); } }; useEffect(() => { getFeed(); }, []); const loadingSpinner = loading ? : null; const noNews = !loading && feed.length === 0 ?
No news.
: null; return (
News & Updates from Owncast {loadingSpinner} {feed.map(item => ( ))} {noNews}
); };