|
1 | 1 | import { GetStaticProps } from "next"; |
2 | | -import { Alert, Card, Skeleton, Stack, Text, Title } from "@mantine/core"; |
3 | | -import { IconAlertCircle } from "@tabler/icons-react"; |
| 2 | +import { Card, Flex, Stack, Text, Title } from "@mantine/core"; |
4 | 3 | import Link from "next/link"; |
5 | 4 | import { type IPost } from "../api-types"; |
6 | 5 |
|
@@ -39,43 +38,31 @@ export default function HomePage({ posts, error }: HomePageProps) { |
39 | 38 | return ( |
40 | 39 | <Stack> |
41 | 40 | <Title order={2}>Your Home Feed</Title> |
42 | | - <Stack gap="md"> |
43 | | - {error ? ( |
44 | | - <Alert |
45 | | - icon={<IconAlertCircle size="1rem" />} |
46 | | - title="Bummer!" |
47 | | - color="red" |
| 41 | + <Flex gap="md" wrap="wrap"> |
| 42 | + {posts?.map((post) => ( |
| 43 | + <Link |
| 44 | + key={post.id} |
| 45 | + href={`/posts/${post.id}`} |
| 46 | + style={{ textDecoration: "none" }} |
48 | 47 | > |
49 | | - There was an error fetching posts |
50 | | - </Alert> |
51 | | - ) : !posts.length ? ( |
52 | | - [...Array(5)].map((_, index) => ( |
53 | | - <Card withBorder shadow="md" key={index}> |
54 | | - <Skeleton animate height="20px" width="50%" mb="md" /> |
55 | | - <Skeleton animate height="40px" width="100%" mb="md" /> |
56 | | - </Card> |
57 | | - )) |
58 | | - ) : ( |
59 | | - posts.map((post) => ( |
60 | | - <Link |
61 | | - key={post.id} |
62 | | - href={`/posts/${post.id}`} |
63 | | - style={{ textDecoration: "none" }} |
| 48 | + <Card |
| 49 | + mih={320} |
| 50 | + shadow="md" |
| 51 | + w={300} |
| 52 | + withBorder |
| 53 | + style={{ |
| 54 | + cursor: "pointer", |
| 55 | + }} |
64 | 56 | > |
65 | | - <Card |
66 | | - withBorder |
67 | | - shadow="md" |
68 | | - style={{ |
69 | | - cursor: "pointer", |
70 | | - }} |
71 | | - > |
72 | | - <Title order={3}>{post.title}</Title> |
73 | | - <Text>{post.body}</Text> |
74 | | - </Card> |
75 | | - </Link> |
76 | | - )) |
77 | | - )} |
78 | | - </Stack> |
| 57 | + <Title order={3}>{post.title}</Title> |
| 58 | + <Text>{post.body}</Text> |
| 59 | + <Text c="blue" pt="md"> |
| 60 | + Go to post |
| 61 | + </Text> |
| 62 | + </Card> |
| 63 | + </Link> |
| 64 | + ))} |
| 65 | + </Flex> |
79 | 66 | </Stack> |
80 | 67 | ); |
81 | 68 | } |
0 commit comments