Skip to content

Instantly share code, notes, and snippets.

@zsherman
Created August 16, 2017 15:56
Show Gist options
  • Save zsherman/ac007ec9e39d6f54f42bc3f6bf01f92b to your computer and use it in GitHub Desktop.
Save zsherman/ac007ec9e39d6f54f42bc3f6bf01f92b to your computer and use it in GitHub Desktop.
import React from 'react'
import Link from 'next/link'
import styled from 'styled-components'
import Layout from 'layouts/Main';
import { getPost } from 'api/posts'
const PostPage = ({ post }) => (
<Layout>
<h1>{post.title}</h1>
<p>{post.body}</p>
</Layout>
)
PostPage.getInitialProps = async ({ query }) => {
const res = await getPost(query.slug)
const json = await res.json()
return { post: json[0] }
}
export default PostPage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment