import React from "react"; import { GetServerSideProps } from "next"; import Layout from "../components/Layout"; import Post from "../components/Post"; import { PostProps } from "./blog/[id]"; import { client, e } from "../client"; type Props = { drafts: PostProps[]; }; const Drafts: React.FC = (props) => { return (

Drafts

{props.drafts.length ? props.drafts.map((post) => (
)) : "No drafts yet."}
); }; export const getServerSideProps: GetServerSideProps = async () => { const drafts = await e .select(e.Post, (post) => ({ id: true, title: true, content: true, authorName: true, filter: e.op("not", e.op("exists", post.published)), })) .run(client); return { props: { drafts }, }; }; export default Drafts;