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'; import { formatDistance } from 'date-fns'; const displaySection = (blog) => { if (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(
{formatDistance(article.publishedAt, new Date(), { addSuffix: true, })}
{article.description}
No recent post