forked from mikemajara/nextjs-prisma-next-auth-credentials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
52 lines (48 loc) · 1.07 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React from "react";
import { GetStaticProps } from "next";
import Layout from "../components/Layout";
import Post, { PostProps } from "../components/Post";
import prisma from "../lib/prisma";
import { Box, Heading, VStack } from "@chakra-ui/react";
export const getStaticProps: GetStaticProps = async () => {
const feed = await prisma.post.findMany({
where: {
published: true,
},
include: {
author: {
select: {
name: true,
},
},
},
});
return {
props: { feed },
};
};
type Props = {
feed: PostProps[];
};
const Blog: React.FC<Props> = (props) => {
return (
<Layout>
<Box className="page" pt={5}>
<Heading>Public Feed</Heading>
<VStack mt={5} spacing={5}>
{props.feed.map((post) => (
<Box
key={post.id}
w="full"
shadow="lg"
_active={{ shadow: "unset" }}
>
<Post post={post} />
</Box>
))}
</VStack>
</Box>
</Layout>
);
};
export default Blog;