import moment from 'moment'; import { Fragment, useEffect, useState } from 'react'; import { ga, skeleton } from '../../helpers/utils'; import LazyImage from '../lazy-image'; import PropTypes from 'prop-types'; import { AiOutlineContainer } from 'react-icons/ai'; import { getDevPost, getMediumPost } from '@arifszn/blog-js'; const displaySection = (blog) => { if ( typeof blog !== 'undefined' && typeof blog.source !== 'undefined' && typeof blog.username !== 'undefined' && blog.source && blog.username ) { return true; } else { return false; } }; const Blog = ({ loading, blog, googleAnalytics }) => { const [articles, setArticles] = useState(null); useEffect(() => { if (displaySection(blog)) { if (blog.source === 'medium') { getMediumPost({ user: blog.username, }).then((res) => { setArticles(res); }); } else if (blog.source === 'dev') { getDevPost({ user: blog.username, }).then((res) => { setArticles(res); }); } } }, []); const renderSkeleton = () => { let array = []; for (let index = 0; index < blog.limit; index++) { array.push(
{moment(article.publishedAt).fromNow()}
{article.description}
No recent post