-
-
Save zsherman/6a34a5974ab19dac5edaa4abfc98d18b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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