Initial commit from Create Next App
This commit is contained in:
37
pages/users/index.tsx
Normal file
37
pages/users/index.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { GetStaticProps } from 'next'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { User } from '../../interfaces'
|
||||
import { sampleUserData } from '../../utils/sample-data'
|
||||
import Layout from '../../components/Layout'
|
||||
import List from '../../components/List'
|
||||
|
||||
type Props = {
|
||||
items: User[]
|
||||
}
|
||||
|
||||
const WithStaticProps = ({ items }: Props) => (
|
||||
<Layout title="Users List | Next.js + TypeScript Example">
|
||||
<h1>Users List</h1>
|
||||
<p>
|
||||
Example fetching data from inside <code>getStaticProps()</code>.
|
||||
</p>
|
||||
<p>You are currently on: /users</p>
|
||||
<List items={items} />
|
||||
<p>
|
||||
<Link href="/">
|
||||
<a>Go home</a>
|
||||
</Link>
|
||||
</p>
|
||||
</Layout>
|
||||
)
|
||||
|
||||
export const getStaticProps: GetStaticProps = async () => {
|
||||
// Example for including static props in a Next.js function component page.
|
||||
// Don't forget to include the respective types for any props passed into
|
||||
// the component.
|
||||
const items: User[] = sampleUserData
|
||||
return { props: { items } }
|
||||
}
|
||||
|
||||
export default WithStaticProps
|
Reference in New Issue
Block a user