Fix date issues
This commit is contained in:
parent
c17a5728a3
commit
03e63e1806
|
@ -20,7 +20,7 @@
|
||||||
"front-matter": "^2.2.0",
|
"front-matter": "^2.2.0",
|
||||||
"jsonfile": "^4.0.0",
|
"jsonfile": "^4.0.0",
|
||||||
"markdown-it": "^8.4.2",
|
"markdown-it": "^8.4.2",
|
||||||
"moment": "^2.19.1",
|
"moment": "^2.24.0",
|
||||||
"node-sass": "^4.9.0",
|
"node-sass": "^4.9.0",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
"react": "^16.7.0",
|
"react": "^16.7.0",
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default class Blog extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
let posts = this.props.posts.sort((a, b) => {
|
let posts = this.props.posts.sort((a, b) => {
|
||||||
return a.data - b.date
|
return new Date(b.published) - new Date(a.published)
|
||||||
})
|
})
|
||||||
let postsHTML = posts.map((post) =>
|
let postsHTML = posts.map((post) =>
|
||||||
<tr className={styles.postListItem} key={post.title}>
|
<tr className={styles.postListItem} key={post.title}>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import contentStyle from '../static/stylesheets/content.scss'
|
||||||
import styles from './Post.scss'
|
import styles from './Post.scss'
|
||||||
import MarkdownIt from 'markdown-it'
|
import MarkdownIt from 'markdown-it'
|
||||||
import fm from 'front-matter'
|
import fm from 'front-matter'
|
||||||
|
import moment from 'moment'
|
||||||
|
|
||||||
export default class Post extends Component {
|
export default class Post extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -17,7 +18,7 @@ export default class Post extends Component {
|
||||||
const md = MarkdownIt()
|
const md = MarkdownIt()
|
||||||
const content = fm(this.props.post)
|
const content = fm(this.props.post)
|
||||||
const title = content.attributes.title
|
const title = content.attributes.title
|
||||||
const date = content.attributes.date
|
const date = moment(content.attributes.date, 'YYYY-MM-DD')
|
||||||
const body = md.render(content.body)
|
const body = md.render(content.body)
|
||||||
|
|
||||||
if (this.props.isLoading) {
|
if (this.props.isLoading) {
|
||||||
|
@ -35,7 +36,7 @@ export default class Post extends Component {
|
||||||
<Header header={title} />
|
<Header header={title} />
|
||||||
<div className={contentStyle.content}>
|
<div className={contentStyle.content}>
|
||||||
<div className={styles.postDate}>
|
<div className={styles.postDate}>
|
||||||
<h3>{date}</h3>
|
<h3>{date.format('MMMM D, YYYY')}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.postContent} dangerouslySetInnerHTML={{ __html: body }}>
|
<div className={styles.postContent} dangerouslySetInnerHTML={{ __html: body }}>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,7 +28,6 @@ export default class MainContainer extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
console.log(this.state)
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Home/>
|
<Home/>
|
||||||
|
|
|
@ -19,8 +19,6 @@ export default class PostContainer extends Component {
|
||||||
post = props.staticContext.data
|
post = props.staticContext.data
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(post)
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isLoading: !post,
|
isLoading: !post,
|
||||||
error: false,
|
error: false,
|
||||||
|
|
|
@ -5256,9 +5256,10 @@ mixin-object@^2.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
minimist "0.0.8"
|
minimist "0.0.8"
|
||||||
|
|
||||||
moment@^2.19.1:
|
moment@^2.24.0:
|
||||||
version "2.22.1"
|
version "2.24.0"
|
||||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad"
|
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
|
||||||
|
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
|
||||||
|
|
||||||
move-concurrently@^1.0.1:
|
move-concurrently@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
|
|
Loading…
Reference in New Issue