Fix date issues

This commit is contained in:
LordMathis 2019-03-27 17:15:05 +01:00
parent c17a5728a3
commit 03e63e1806
6 changed files with 9 additions and 10 deletions

View File

@ -20,7 +20,7 @@
"front-matter": "^2.2.0",
"jsonfile": "^4.0.0",
"markdown-it": "^8.4.2",
"moment": "^2.19.1",
"moment": "^2.24.0",
"node-sass": "^4.9.0",
"prop-types": "^15.7.2",
"react": "^16.7.0",

View File

@ -21,7 +21,7 @@ export default class Blog extends Component {
}
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) =>
<tr className={styles.postListItem} key={post.title}>

View File

@ -6,6 +6,7 @@ import contentStyle from '../static/stylesheets/content.scss'
import styles from './Post.scss'
import MarkdownIt from 'markdown-it'
import fm from 'front-matter'
import moment from 'moment'
export default class Post extends Component {
static propTypes = {
@ -17,7 +18,7 @@ export default class Post extends Component {
const md = MarkdownIt()
const content = fm(this.props.post)
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)
if (this.props.isLoading) {
@ -35,7 +36,7 @@ export default class Post extends Component {
<Header header={title} />
<div className={contentStyle.content}>
<div className={styles.postDate}>
<h3>{date}</h3>
<h3>{date.format('MMMM D, YYYY')}</h3>
</div>
<div className={styles.postContent} dangerouslySetInnerHTML={{ __html: body }}>
</div>

View File

@ -28,7 +28,6 @@ export default class MainContainer extends Component {
}
render () {
console.log(this.state)
return (
<div>
<Home/>

View File

@ -19,8 +19,6 @@ export default class PostContainer extends Component {
post = props.staticContext.data
}
console.log(post)
this.state = {
isLoading: !post,
error: false,

View File

@ -5256,9 +5256,10 @@ mixin-object@^2.0.1:
dependencies:
minimist "0.0.8"
moment@^2.19.1:
version "2.22.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad"
moment@^2.24.0:
version "2.24.0"
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:
version "1.0.1"