react-static
Version:
A progressive static site generator for React
32 lines (29 loc) • 719 B
JavaScript
import React from 'react'
import { withRouteData, Switch, Route, Link } from 'react-static'
//
import Post from './Post'
export default withRouteData(({ match, posts }) => (
<div>
<Switch>
<Route
path={match.url}
exact
render={() => (
<div>
<h1>It's blog time.</h1>
<br />
All Posts:
<ul>
{posts.map(post => (
<li key={post.id}>
<Link to={`/blog/post/${post.id}/`}>{post.title}</Link>
</li>
))}
</ul>
</div>
)}
/>
<Route path={`${match.url}/post/:postID/`} component={Post} />
</Switch>
</div>
))