forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
35 lines (30 loc) · 813 Bytes
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Head from 'next/head'
import { GetStaticProps, NextPage } from 'next'
import Post from '../components/post'
import { PostData, PostDataListProps } from '../types/postdata'
import { GetPosts } from '../lib/postdata_api'
export const getStaticProps: GetStaticProps = async (_context) => {
// fetch list of posts
const posts: PostData[] = await GetPosts()
return {
props: {
postDataList: posts,
},
}
}
const IndexPage: NextPage<PostDataListProps> = ({ postDataList }: PostDataListProps) => {
return (
<main>
<Head>
<title>Home page</title>
</Head>
<h1>List of posts</h1>
<section>
{postDataList.map((post: PostData) => (
<Post {...post} key={post.id} />
))}
</section>
</main>
)
}
export default IndexPage