rsnext/examples/with-next-sitemap/pages/[dynamic].tsx
Henrik Wenz c2f48ea86d
chore: refactor with-next-sitemap example (#40712)
## Changes

see commits

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-09-20 19:10:22 +00:00

33 lines
620 B
TypeScript

import { GetStaticPaths, GetStaticProps } from 'next'
import { useRouter } from 'next/router'
const DynamicPage = () => {
const { query } = useRouter()
return (
<>
<h1>Dynamic Page</h1>
<h2>Query: {query.dynamic}</h2>
</>
)
}
export const getStaticProps: GetStaticProps = async () => {
return {
props: {
dynamic: 'hello',
},
}
}
export const getStaticPaths: GetStaticPaths = async () => {
return {
paths: [...Array(10000)].map((_, index) => ({
params: {
dynamic: `page-${index}`,
},
})),
fallback: false,
}
}
export default DynamicPage