posts.tsx (938B)
1 import { Container } from "../components/util/container"; 2 import { Section } from "../components/util/section"; 3 import { Posts } from "../components/posts"; 4 import { client } from "../tina/__generated__/client"; 5 import { InferGetStaticPropsType } from "next"; 6 import Layout from "../components/layout/layout"; 7 8 export default function HomePage( 9 props: InferGetStaticPropsType<typeof getStaticProps> 10 ) { 11 const posts = props.data.postConnection.edges; 12 13 return ( 14 <Layout> 15 <Section className="flex-1"> 16 <Container size="large" width="small"> 17 <Posts data={posts} /> 18 </Container> 19 </Section> 20 </Layout> 21 ); 22 } 23 24 export const getStaticProps = async () => { 25 const tinaProps = await client.queries.postConnection(); 26 return { 27 props: { 28 ...tinaProps, 29 }, 30 }; 31 }; 32 33 export type PostsType = InferGetStaticPropsType< 34 typeof getStaticProps 35 >["data"]["postConnection"]["edges"][number];