import Head from "next/head"; import Container from "../components/container"; import MoreStories from "../components/more-stories"; import HeroPost from "../components/hero-post"; import Intro from "../components/intro"; import Layout from "../components/layout"; import { EXAMPLE_TOOL_NAME } from "../lib/constants"; import Post from "../types/post"; import { getAllPostsForHome } from "../lib/api"; type Props = { posts: Post[]; preview: boolean; }; export default function Index({ posts, preview }: Props) { const heroPost = posts[0]; const morePosts = posts.slice(1); return ( <> Next.js Blog Example with {EXAMPLE_TOOL_NAME} {heroPost && ( )} {morePosts.length > 0 && } ); } export async function getStaticProps({ preview }: { preview: boolean }) { const posts = await getAllPostsForHome(preview); return { props: { posts: posts, preview: preview || null, }, }; }