Remove the use of Moment.js.

This is a heavy library that is hardly used, in addition, it is already quite deprecated, see here:
https://momentjs.com/docs/#/-project-status/
This commit is contained in:
Elad Sivan
2020-09-15 14:51:20 +03:00
parent aaab52b87a
commit bdcfa859eb
4 changed files with 3 additions and 407 deletions

View File

@@ -1,6 +1,5 @@
// @flow strict
import React from 'react';
import moment from 'moment';
import { Link } from 'gatsby';
import type { Edges } from '../../types';
import styles from './Feed.module.scss';
@@ -14,8 +13,8 @@ const Feed = ({ edges }: Props) => (
{edges.map((edge) => (
<div className={styles['feed__item']} key={edge.node.fields.slug}>
<div className={styles['feed__item-meta']}>
<time className={styles['feed__item-meta-time']} dateTime={moment(edge.node.frontmatter.date).format('MMMM D, YYYY')}>
{moment(edge.node.frontmatter.date).format('MMMM YYYY')}
<time className={styles['feed__item-meta-time']} dateTime={ new Date(edge.node.frontmatter.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}>
{ new Date(edge.node.frontmatter.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long' })}
</time>
<span className={styles['feed__item-meta-divider']} />
<span className={styles['feed__item-meta-category']}>

View File

@@ -1,6 +1,5 @@
// @flow strict
import React from 'react';
import moment from 'moment';
import styles from './Meta.module.scss';
type Props = {
@@ -9,7 +8,7 @@ type Props = {
const Meta = ({ date }: Props) => (
<div className={styles['meta']}>
<p className={styles['meta__date']}>Published {moment(date).format('D MMM YYYY')}</p>
<p className={styles['meta__date']}>Published {new Date(date).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })}</p>
</div>
);