import { getDevtoArticle, getMediumArticle } from "article-api"; import moment from "moment"; import { Fragment, useContext, useEffect, useState } from "react"; import { CgHashtag } from 'react-icons/cg'; import config from "../config"; import { LoadingContext } from "../contexts/LoadingContext"; import { ga, skeleton } from "../helpers/utils"; import LazyImage from "./LazyImage"; const displaySection = () => { if ( typeof config.blog !== 'undefined' && typeof config.blog.source !== 'undefined' && typeof config.blog.username !== 'undefined' && config.blog.source && config.blog.username ) { return true; } else { return false; } } const Blog = () => { const [articles, setArticles] = useState(null); const [loading] = useContext(LoadingContext); useEffect(() => { if (displaySection()) { 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); }); } } }, []) const renderSkeleton = () => { let array = []; for (let index = 0; index < config.blog.limit; index++) { array.push((
{moment(article.publishedAt).fromNow()}
{article.description}