systems-obscure/src/containers/PostListing.tsx

56 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-07-07 17:08:27 +01:00
// @ts-nocheck
import {
2025-07-20 19:15:26 +01:00
Card,
CardDescription,
CardHeader,
CardTitle,
2025-07-07 17:08:27 +01:00
} from "@/components/ui/card"
import { Button } from "@/components/ui/button"
import { Link } from "react-router"
import { convertDate } from "@/utils/convertDate"
const PostListing = ({ posts, title, showAllButton }) => {
2025-07-20 19:15:26 +01:00
return (
<>
2025-07-31 16:44:15 +01:00
<div className="mb-5">
<h2 className="scroll-m-20 text-[1.3rem] font-semibold border-b pb-2">
2025-07-20 19:15:26 +01:00
{title}
</h2>
</div>
<div className="grid grid-cols-1 md:grid-cols-1 gap-3">
{posts.map((post) => (
<Link
to={`/posts/${post.slug}`}
key={post.slug}
className="block no-underline"
>
<Card
key={post.slug}
className="flex flex-col h-full hover:bg-primary/5 py-4 rounded-none"
>
<CardHeader className="">
<CardTitle className="leading-snug font-semibold ">
{post.title}
</CardTitle>
<CardDescription className="text-sm text-muted-foreground">
<div className="flex justify-between gap-2">
<span className="text-sm">{convertDate(post.date)}</span>
</div>
</CardDescription>
</CardHeader>
</Card>
</Link>
))}
</div>
{showAllButton && (
2025-07-31 16:44:15 +01:00
<Button asChild variant="secondary" className="w-full mt-4">
2025-07-20 19:15:26 +01:00
<Link to="/posts/page/1">View all</Link>
</Button>
)}
</>
)
2025-07-07 17:08:27 +01:00
}
export default PostListing