c9d9f1131c
* Rename getServerProps to getServerSideProps * Remove unstable_ prefix from new methods * Add error when legacy methods are detected * Add legacy methods for babel transform * Add unstable_getServerSideProps also * Apply suggestions from code review Co-Authored-By: Joe Haddad <joe.haddad@zeit.co> * Update types import Co-authored-by: Joe Haddad <timer150@gmail.com>
43 lines
837 B
JavaScript
43 lines
837 B
JavaScript
import React from 'react'
|
|
import Link from 'next/link'
|
|
|
|
// eslint-disable-next-line camelcase
|
|
export async function getStaticPaths() {
|
|
return {
|
|
paths: [
|
|
'/blog/post-1/comment-1',
|
|
{ params: { post: 'post-2', comment: 'comment-2' } },
|
|
],
|
|
fallback: true,
|
|
}
|
|
}
|
|
|
|
// eslint-disable-next-line camelcase
|
|
export async function getStaticProps({ params }) {
|
|
return {
|
|
props: {
|
|
post: params.post,
|
|
comment: params.comment,
|
|
time: new Date().getTime(),
|
|
},
|
|
revalidate: 2,
|
|
}
|
|
}
|
|
|
|
export default ({ post, comment, time }) => {
|
|
// we're in a loading state
|
|
if (!post) {
|
|
return <p>loading...</p>
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<p>Post: {post}</p>
|
|
<p>Comment: {comment}</p>
|
|
<span>time: {time}</span>
|
|
<Link href="/">
|
|
<a id="home">to home</a>
|
|
</Link>
|
|
</>
|
|
)
|
|
}
|