Skip to content

Commit 21bec7d

Browse files
Adding the typescript
1 parent 420d5a7 commit 21bec7d

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/pages/index.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import Card from 'components/Card';
22
import dayjs from 'dayjs';
33
import data from 'data/posts';
44

5-
export default function Home({posts}) {
5+
export default function Home({posts}:indexComponent ) {
66
return (
77
<main className="container">
88

99
{
10-
posts.map(item=> <Card
10+
posts.map( (item: indexPropsComponent) => <Card
1111

1212
key={item.id}
1313

@@ -30,11 +30,32 @@ export default function Home({posts}) {
3030
)
3131
}
3232

33-
export async function getStaticProps(context) {
34-
35-
33+
export async function getStaticProps() {
3634

3735
return {
3836
props: { posts:data },
3937
}
38+
}
39+
40+
interface indexComponent {
41+
posts : {
42+
[x: string]: any;
43+
tags: string;
44+
date: string;
45+
title: string;
46+
description: string;
47+
image: string;
48+
author: string;
49+
}
50+
}
51+
52+
interface indexPropsComponent {
53+
id: string;
54+
tags: string;
55+
date: string;
56+
title: string;
57+
description: string;
58+
image: string;
59+
author: string;
60+
4061
}

0 commit comments

Comments
 (0)