Replace moment with date-fns

This commit is contained in:
Ariful Alam
2022-05-19 19:38:55 +06:00
parent 36097918fd
commit 6b3d089b4b
4 changed files with 34 additions and 24 deletions

View File

@@ -1,10 +1,10 @@
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';
import { formatDistance } from 'date-fns';
const displaySection = (blog) => {
if (
@@ -147,7 +147,9 @@ const Blog = ({ loading, blog, googleAnalytics }) => {
{article.title}
</h2>
<p className="opacity-50 text-xs">
{moment(article.publishedAt).fromNow()}
{formatDistance(article.publishedAt, new Date(), {
addSuffix: true,
})}
</p>
<p className="mt-3 text-base-content text-opacity-60 text-sm">
{article.description}