import * as React from "react" import { Heading, NavLinks, Tabs, GuideCard, Text } from "../../writer" import * as cn from "./PageBlogHome.styles" import { PageBlogHomeProps, BlogPost, BlogTab } from "./types" export function PageBlogHome({ posts = [], tabs = [], initialTab, heading, subheading, prevLink, nextLink, as = "", }: PageBlogHomeProps) { const [tab, setTab] = React.useState(initialTab || (tabs && tabs[0]?.value) || "") const filteredPosts = React.useMemo(() => { if (tab === "everything") return posts return posts?.filter(post => post.tag.toLowerCase() === tab) }, [tab, posts]) return {heading} {tabs.map(t => ( {t.label} ))}
{filteredPosts.map(post => (
{post.title}
{post.tag} {post.title}
{post.author.name} {post.author.name} {post.date}
))}
}