Skip to content

Commit 59eba99

Browse files
committed
All Posts Page Implemented
1 parent 8e64390 commit 59eba99

File tree

5 files changed

+83
-6
lines changed

5 files changed

+83
-6
lines changed

_posts/welcome-to-sesc.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ So, what do you think? Ready to dive in and be part of the SESC experience? Foll
7777

7878
Have questions or suggestions? Want to know more about upcoming events? Reach out to us via:
7979

80-
Email: (sesc@sliit.lk)[sesc@sliit.lk]
81-
Facebook: (sliitsecommunity)[https://web.facebook.com/sliitsecommunity]
82-
Instagram: (@sliit.sesc)[https://www.instagram.com/sliit.sesc]
83-
LinkedIn: (Software Enginineering Student Community)[https://www.linkedin.com/company/sesc-sliit/]
80+
Email: [sesc@sliit.lk](mailto:sesc@sliit.lk)
81+
Facebook: [sliitsecommunity](https://web.facebook.com/sliitsecommunity)
82+
Instagram: [@sliit.sesc](https://www.instagram.com/sliit.sesc)
83+
LinkedIn: [Software Engineering Student Community](https://www.linkedin.com/company/sesc-sliit/)
8484

8585
Let’s connect, collaborate, and code our way to the future!
8686

src/app/_components/Navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default function Navbar() {
8585
<Link href="/">Home</Link>
8686
</li>
8787
<li className="mt-4 md:mt-0 hover:text-black hover:underline underline-offset-2">
88-
<Link href="/">All Posts</Link>
88+
<Link href="/allposts">All Posts</Link>
8989
</li>
9090
<li className="mt-4 md:mt-0 hover:text-black hover:underline underline-offset-2">
9191
<Link href="/about">About</Link>

src/app/allposts/page.tsx

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
}

src/app/layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export default function RootLayout({
6464
className={cn(
6565
spacegrotesk.className,
6666
"dark:bg-slate-900 dark:text-slate-400"
67-
)}>
67+
)}
68+
>
6869
<Navbar />
6970
<div className="min-h-screen">{children}</div>
7071
</body>

src/interfaces/post.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { type Author } from "./author";
22

33
export type Post = {
4+
categories: any;
45
slug: string;
56
title: string;
67
date: string;

0 commit comments

Comments
 (0)