<commit_before>import React, { PropTypes, Component } from 'react';
import getPosts from '../helpers/getPosts'
import PostText from './PostText'
import postsDates from '../data/posts_dates.json';

export default class Posts extends Component {
  static propTypes = {
    short: PropTypes.bool.isRequired
  }

  formatDate = (d) => {
    const dateObject = new Date(d);
    return dateObject.getFullYear() + '.' + (dateObject.getMonth() + 1) + '.' + dateObject.getDate();
  }

  renderPosts = () => (
    getPosts().map((p, ind) => {
      const postDate = postsDates[p.filename]
      const text = require(`../posts/${p.category}/${p.filename}`);
      return (
        <PostText
          key={'post'+ind}
          short={this.props.short}
          postDate={postDate}
          formattedDate={this.formatDate(postDate)}
          slugifiedCategory={p.slugifiedCategory}
          category={p.category}
          text={text}
          url={p.slugifiedUrl}
        />
      )
    })
  )

  render() {
    return (
      <div>{this.renderPosts()}</div><commit_msg>Refactor Posts -- add date prop to post object<commit_after>import React, { PropTypes, Component } from 'react'
import R from 'ramda'
import getPosts from '../helpers/getPosts'
import PostText from './PostText'
import postsDates from '../data/posts_dates.json'

export default class Posts extends Component {
  static propTypes = {
    short: PropTypes.bool.isRequired
  }

  formatDate = (d) => {
    const dateObject = new Date(d);
    return dateObject.getFullYear() + '.' + (dateObject.getMonth() + 1) + '.' + dateObject.getDate();
  }

  postsWithDate = () => {
    const posts = getPosts()
    let newPosts = []
    posts.forEach(p => {
      let post = Object.assign({}, p, { postDate: postsDates[p.filename] })
      newPosts.push(post)
    })
    return newPosts
  }

  renderPosts = () => (
    this.postsWithDate().map((p, ind) => {
      const text = require(`../posts/${p.category}/${p.filename}`);
      return (
        <PostText
          key={'post'+ind}
          short={this.props.short}
          postDate={p.postDate}
          formattedDate={this.formatDate(p.postDate)}
          slugifiedCategory={p.slugifiedCategory}
          category={p.category}
          text={text}
          url={p.slugifiedUrl}
        />
      )
    })
  )

  render() {
    return (
      <div>{this.renderPosts()}</div>
{'fraction_non_alphanumeric': 0.15416841223292838, 'fraction_numerical': 0.0008378718056137411, 'mean_word_length': 2.5535714285714284, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4510461', 'n_tokens_mistral': 747, 'n_tokens_neox': 737, 'n_words': 145}