import { getDevtoArticle, getMediumArticle } from "article-api"; import moment from "moment"; import { memo, useEffect, useState } from "react"; import { CgHashtag } from 'react-icons/cg'; import config from "../config"; import { skeleton } from "../helpers/utils"; const Blog = () => { const [articles, setArticles] = useState(null); useEffect(() => { if ( typeof config.blog !== 'undefined' && typeof config.blog.source !== 'undefined' && typeof config.blog.username !== 'undefined' && config.blog.source && config.blog.username ) { if (config.blog.source === 'medium') { getMediumArticle({ user: config.blog.username }) .then(res => { setArticles(res); }); } else if (config.blog.source === 'dev.to') { getDevtoArticle({ user: config.blog.username }) .then(res => { setArticles(res); }); } } }, []) return (
  • {!articles ? skeleton({width: 'w-28', height: 'h-8'}) : 'Recent Posts'}
    { !articles ? skeleton({width: 'w-8', height: 'h-8'}) : ( ) }
{ articles && articles.slice(0, 5).map((article, index) => (
{'thumbnail'}/

{article.title}

{moment(article.publishedAt).fromNow()}

{article.description}

{ article.categories.map((category, index2) => (
{category}
)) }
)) }
) } export default memo(Blog);