-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathindex.tsx
61 lines (55 loc) · 1.17 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
53
54
55
56
57
58
59
60
61
import React from "react";
import type { GetStaticProps } from "next";
import Layout from "../components/Layout";
import Post, { PostProps } from "../components/Post";
import prisma from '../lib/prisma'
export const getStaticProps: GetStaticProps = async () => {
const feed = await prisma.post.findMany({
where: {
published: true,
},
include: {
author: {
select: {
name: true,
},
},
},
});
return {
props: { feed },
revalidate: 10,
};
};
type Props = {
feed: PostProps[];
};
const Blog: React.FC<Props> = (props) => {
return (
<Layout>
<div className="page">
<h1>Public Feed</h1>
<main>
{props.feed.map((post) => (
<div key={post.id} className="post">
<Post post={post} />
</div>
))}
</main>
</div>
<style jsx>{`
.post {
background: white;
transition: box-shadow 0.1s ease-in;
}
.post:hover {
box-shadow: 1px 1px 3px #aaa;
}
.post + .post {
margin-top: 2rem;
}
`}</style>
</Layout>
);
};
export default Blog;