'use client' import { Heading, Stack, Text } from '@chakra-ui/react' import { Link } from '@chakra-ui/next-js' type Props = { allBlogs: { metadata: { title: string publishedAt: string } slug: string }[] } export const Posts = ({ allBlogs }: Props) => ( Latest blog posts: {allBlogs .filter((post) => post.metadata.publishedAt) .sort((a, b) => { if ( new Date(a.metadata.publishedAt) > new Date(b.metadata.publishedAt) ) { return -1 } return 1 }) .map((post) => ( {post.metadata.title} {new Date(post.metadata.publishedAt).toDateString()} ))} )