Skip to content

Commit b6fb888

Browse files
committed
Dates are pre-formatted GraphQL query
1 parent c3e5951 commit b6fb888

File tree

4 files changed

+6
-27
lines changed

4 files changed

+6
-27
lines changed

www/src/pages/blog/all.html.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Container from 'components/Container';
1616
import Header from 'components/Header';
1717
import React from 'react';
1818
import {sharedStyles} from 'theme';
19-
import dateToString from 'utils/dateToString';
2019
import toCommaSeparatedList from 'utils/toCommaSeparatedList';
2120

2221
const AllBlogPosts = ({data}) => (
@@ -38,7 +37,7 @@ const AllBlogPosts = ({data}) => (
3837
{' '}
3938
on
4039
{' '}
41-
{dateToString(new Date(node.fields.date))}
40+
{node.fields.date}
4241
{' '}
4342
by
4443
{' '}
@@ -72,7 +71,7 @@ export const pageQuery = graphql`
7271
}
7372
}
7473
fields {
75-
date
74+
date(formatString: "MMMM DD, YYYY")
7675
slug
7776
}
7877
}

www/src/templates/blog.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const toSectionList = allMarkdownRemark => [
3434
const Blog = ({data, location}) => (
3535
<MarkdownPage
3636
authors={data.markdownRemark.frontmatter.author}
37-
date={new Date(data.markdownRemark.fields.date)}
37+
date={data.markdownRemark.fields.date}
3838
location={location}
3939
markdownRemark={data.markdownRemark}
4040
sectionList={toSectionList(data.allMarkdownRemark)}
@@ -62,7 +62,7 @@ export const pageQuery = graphql`
6262
}
6363
}
6464
fields {
65-
date
65+
date(formatString: "MMMM DD, YYYY")
6666
path
6767
}
6868
}

www/src/templates/components/MarkdownPage/MarkdownPage.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {StickyContainer} from 'react-sticky';
1919
import PropTypes from 'prop-types';
2020
import React from 'react';
2121
import StickySidebar from '../StickySidebar';
22-
import dateToString from 'utils/dateToString';
2322
import findSectionForPath from 'utils/findSectionForPath';
2423
import toCommaSeparatedList from 'utils/toCommaSeparatedList';
2524
import {sharedStyles} from 'theme';
@@ -62,7 +61,7 @@ const MarkdownPage = ({
6261

6362
{(date || hasAuthors) &&
6463
<div css={{marginTop: 15}}>
65-
{date ? `${dateToString(date)} ` : ''}
64+
{date}{' '}
6665
{hasAuthors &&
6766
<span>
6867
by {toCommaSeparatedList(authors, author => (
@@ -122,7 +121,7 @@ MarkdownPage.defaultProps = {
122121
// TODO Better types
123122
MarkdownPage.propTypes = {
124123
authors: PropTypes.array.isRequired,
125-
date: PropTypes.object,
124+
date: PropTypes.string,
126125
location: PropTypes.object.isRequired,
127126
markdownRemark: PropTypes.object.isRequired,
128127
sectionList: PropTypes.array.isRequired,

www/src/utils/dateToString.js

-19
This file was deleted.

0 commit comments

Comments
 (0)