Skip to content

Instantly share code, notes, and snippets.

@zsherman
Created August 16, 2017 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsherman/6a34a5974ab19dac5edaa4abfc98d18b to your computer and use it in GitHub Desktop.
Save zsherman/6a34a5974ab19dac5edaa4abfc98d18b to your computer and use it in GitHub Desktop.
import React from 'react'
import Layout from 'layouts/Main';
import { getPosts } from 'api/posts'
import { Link } from 'routes'
import Post from 'components/Post'
const IndexPage = ({ posts }) => (
<Layout>
<ul>
{posts.map(p => (
<Post key={p.title} post={p} />
))}
</ul>
</Layout>
)
IndexPage.getInitialProps = async ({ req }) => {
const res = await getPosts()
const json = await res.json()
return { posts: json }
}
export default IndexPage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment