first commit
This commit is contained in:
commit
6857e301fa
23 files changed
+5500
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import React from "react";
|
||||
import type { GetServerSideProps } from "next";
|
||||
import Layout from "../components/Layout";
|
||||
import Post, { PostProps } from "../components/Post";
|
||||
import prisma from '../lib/prisma'
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = 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>
|
||||
<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;
|
||||
Reference in new issue
Block a user