|
| 1 | +import Container from "../_components/container"; |
| 2 | +import Image from "next/image"; |
| 3 | +import Link from "next/link"; |
| 4 | +import { getAllPosts } from "@/lib/api"; |
| 5 | + |
| 6 | +export default function BlogListing() { |
| 7 | + const blogPosts = getAllPosts(); |
| 8 | + |
| 9 | + return ( |
| 10 | + <Container> |
| 11 | + <div className="text-center mb-12 mt-12"> |
| 12 | + <h1 className="text-3xl md:text-4xl font-bold tracking-tighter leading-tight md:leading-none mb-2 md:mb-4"> |
| 13 | + Featured Posts |
| 14 | + </h1> |
| 15 | + <p className="text-lg md:text-xl text-gray-600 max-w-2xl mx-auto px-4 md:px-0"> |
| 16 | + Explore our latest insights, tutorials, and updates from the world of |
| 17 | + software engineering. Stay informed and inspired! |
| 18 | + </p> |
| 19 | + </div> |
| 20 | + <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8"> |
| 21 | + {blogPosts.map((post) => ( |
| 22 | + <div |
| 23 | + key={post.slug} |
| 24 | + className="bg-white rounded-lg shadow-md overflow-hidden flex flex-col transition-transform duration-300 hover:shadow-lg hover:-translate-y-1" |
| 25 | + > |
| 26 | + <Link href={`/posts/${post.slug}`}> |
| 27 | + <Image |
| 28 | + src={post.coverImage} |
| 29 | + alt={`Cover image for ${post.title}`} |
| 30 | + width={600} |
| 31 | + height={400} |
| 32 | + className="w-full h-48 object-cover" |
| 33 | + /> |
| 34 | + </Link> |
| 35 | + |
| 36 | + <div className="p-6 flex-grow flex flex-col"> |
| 37 | + <h2 className="text-2xl font-bold mb-2 text-dark-blue"> |
| 38 | + <Link href={`/posts/${post.slug}`} className="hover:underline"> |
| 39 | + {post.title} |
| 40 | + </Link> |
| 41 | + </h2> |
| 42 | + <div className="flex justify-between items-center text-sm text-gray-500 mt-auto"> |
| 43 | + <span className="flex items-center"> |
| 44 | + <Image |
| 45 | + src={post.author.picture} |
| 46 | + alt={post.author.name} |
| 47 | + width={24} |
| 48 | + height={24} |
| 49 | + className="rounded-full mr-2" |
| 50 | + /> |
| 51 | + By {post.author.name} |
| 52 | + </span> |
| 53 | + <span> |
| 54 | + {new Date(post.date).toLocaleDateString("en-US", { |
| 55 | + year: "numeric", |
| 56 | + month: "long", |
| 57 | + day: "numeric", |
| 58 | + })} |
| 59 | + </span> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + </div> |
| 63 | + ))} |
| 64 | + </div> |
| 65 | + <div className="text-center mt-12"> |
| 66 | + <Link |
| 67 | + href="/archive" |
| 68 | + className="inline-block bg-dark-blue text-white px-6 py-3 rounded-md hover:bg-blue-700 transition-colors duration-300" |
| 69 | + > |
| 70 | + View All Articles |
| 71 | + </Link> |
| 72 | + </div> |
| 73 | + </Container> |
| 74 | + ); |
| 75 | +} |
0 commit comments