mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
BREAKING CHANGE Since `next export` has been printing a deprecation warning since https://github.com/vercel/next.js/pull/47376, its safe to remove in semver-major. The upgrade path is to simply add `output: 'export'` in `next.config.js` - everything will continue to work the same. This config greatly improves the `next dev` experience today. And in the future, it will improve performance of `next build` because we no longer need to do two passes (build then export).
61 lines
1.2 KiB
JavaScript
61 lines
1.2 KiB
JavaScript
import React from 'react'
|
|
import Link from 'next/link'
|
|
import { useRouter } from 'next/router'
|
|
import 'firebase/firestore'
|
|
|
|
export async function getStaticPaths() {
|
|
return {
|
|
paths: [
|
|
'/blog/post-1',
|
|
{ params: { post: 'post-2' } },
|
|
'/blog/[post3]',
|
|
'/blog/post-4',
|
|
'/blog/post.1',
|
|
'/blog/post.1', // handle duplicates
|
|
],
|
|
fallback: false,
|
|
}
|
|
}
|
|
|
|
let counter = 0
|
|
|
|
export async function getStaticProps({ params }) {
|
|
if (params.post === 'post-10') {
|
|
await new Promise((resolve) => {
|
|
setTimeout(() => resolve(), 1000)
|
|
})
|
|
}
|
|
|
|
if (params.post === 'post-100') {
|
|
throw new Error('such broken..')
|
|
}
|
|
|
|
if (params.post === 'post-999') {
|
|
if (++counter < 6) {
|
|
throw new Error('try again..')
|
|
}
|
|
}
|
|
|
|
return {
|
|
props: {
|
|
params,
|
|
post: params.post,
|
|
time: (await import('perf_hooks')).performance.now(),
|
|
},
|
|
}
|
|
}
|
|
|
|
export default ({ post, time, params }) => {
|
|
return (
|
|
<>
|
|
<p>Post: {post}</p>
|
|
<span>time: {time}</span>
|
|
<div id="params">{JSON.stringify(params)}</div>
|
|
<div id="query">{JSON.stringify(useRouter().query)}</div>
|
|
<Link href="/" id="home">
|
|
to home
|
|
</Link>
|
|
</>
|
|
)
|
|
}
|