import React from 'react'
import { withRouteData, Link } from 'react-static'
//

import Post from 'templates/Post'

export default withRouteData(({ posts }) => (
  <Router>
    <div path="/">
      <h1>It's blog time.</h1>
      <br />
      All Posts:
      <ul>
        {posts.map(post => (
          <li key={post.id}>
            <Link to={`post/${post.id}/`}>{post.title}</Link>
          </li>
        ))}
      </ul>
    </div>
    <Post path="post/:id" />
  </Router>
))
