Skip to content

Commit fcae7c9

Browse files
nirnejaktyaga001coderabbitai[bot]
authored
Blog layout (#165)
* AGENTS.md added * Update AGENTS.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Blog: grid layout for featured blog then all blogs * Blog: 3 blogs as featured * Blog: new on home, 3 featured on list page --------- Co-authored-by: Ankur Tyagi <tyaga001@live.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3567019 commit fcae7c9

File tree

3 files changed

+98
-14
lines changed

3 files changed

+98
-14
lines changed

src/app/blog/data.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const allBlogs = [
3535
category: "Database",
3636
image: EloqdocVSMongoDBPart3.src,
3737
isNew: true,
38-
isFeatured: true,
38+
isFeatured: false,
3939
},
4040
{
4141
author: "Ankur Tyagi",
@@ -49,7 +49,7 @@ export const allBlogs = [
4949
category: "AI Code Editor",
5050
image: CursorVSClaudeCode.src,
5151
isNew: true,
52-
isFeatured: true,
52+
isFeatured: false,
5353
},
5454
{
5555
author: "Ankur Tyagi",
@@ -63,7 +63,7 @@ export const allBlogs = [
6363
category: "Database",
6464
image: EloqdocVSMongoDBPart2.src,
6565
isNew: true,
66-
isFeatured: true,
66+
isFeatured: false,
6767
},
6868
{
6969
author: "Ankur Tyagi",
@@ -75,8 +75,8 @@ export const allBlogs = [
7575
publishedAt: "2026-01-02T00:00:00Z",
7676
category: "Database",
7777
image: EloqdocVSMongoDB.src,
78-
isNew: true,
79-
isFeatured: true,
78+
isNew: false,
79+
isFeatured: false,
8080
},
8181
{
8282
author: "Jitendra Nirnejak",
@@ -89,7 +89,7 @@ export const allBlogs = [
8989
publishedAt: "2025-11-12T00:00:00Z",
9090
category: "Python",
9191
image: RuffAndUvImage.src,
92-
isNew: true,
92+
isNew: false,
9393
isFeatured: true,
9494
},
9595
{
@@ -101,7 +101,7 @@ export const allBlogs = [
101101
publishedAt: "2025-10-21T00:00:00Z",
102102
category: "Code Review",
103103
image: StateOfAICodeReviewCoverImage.src,
104-
isNew: true,
104+
isNew: false,
105105
isFeatured: true,
106106
},
107107
{
@@ -182,7 +182,7 @@ export const allBlogs = [
182182
image: CodeRabbitCoverImage.src,
183183
category: "Code Review",
184184
isNew: false,
185-
isFeatured: true,
185+
isFeatured: false,
186186
},
187187
{
188188
author: "Hrutik Kumthekar",
@@ -208,7 +208,7 @@ export const allBlogs = [
208208
image: SupabaseCoverImage.src,
209209
category: "Auth",
210210
isNew: false,
211-
isFeatured: true,
211+
isFeatured: false,
212212
},
213213
{
214214
author: "Ankur Tyagi",

src/app/blog/page.tsx

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import React from "react"
2+
import Image from "next/image"
13
import { Link } from "next-view-transitions"
4+
import { CircleUserRound, Clock } from "lucide-react"
25

36
import { cn, formatDate } from "@/lib/utils"
47
import { getMetadata } from "@/lib/metadata"
@@ -14,6 +17,74 @@ export const metadata = getMetadata({
1417
image: CoverImage.src,
1518
})
1619

20+
interface BlogCardProps {
21+
index: number
22+
title: string
23+
excerpt: string
24+
author: string
25+
image: string
26+
slug: string
27+
readTime?: string
28+
category: string
29+
isNew?: boolean
30+
}
31+
32+
const BlogCard: React.FC<BlogCardProps> = ({
33+
index,
34+
title,
35+
excerpt,
36+
author,
37+
image,
38+
slug,
39+
readTime,
40+
category,
41+
isNew,
42+
}) => {
43+
const defaultReadTime = "8 min read"
44+
45+
return (
46+
<Link
47+
href={`/blog/${slug}/`}
48+
className={cn(
49+
"flex flex-col transition-colors hover:bg-neutral-900",
50+
"border-b border-dashed border-neutral-100/15",
51+
(index + 1) % 3 !== 0 ? "md:border-r" : ""
52+
)}
53+
>
54+
<div className="relative h-48">
55+
<Image
56+
src={image}
57+
alt={`${title} - ${excerpt}`}
58+
layout="fill"
59+
objectFit="cover"
60+
/>
61+
{isNew && (
62+
<span className="absolute right-2 top-2 rounded-full bg-yellow-400 px-2 py-1 text-xs font-bold text-black">
63+
NEW
64+
</span>
65+
)}
66+
</div>
67+
<div className="p-6">
68+
<span className="mb-2 block text-sm font-medium text-neutral-500">
69+
{category}
70+
</span>
71+
<h3 className="mb-2 text-xl font-bold text-neutral-200">{title}</h3>
72+
<p className="mb-4 text-neutral-500">{excerpt}</p>
73+
</div>
74+
<div className="mt-auto px-6 pb-6">
75+
<div className="flex items-center justify-between text-sm leading-none text-neutral-500">
76+
<p className="flex items-center gap-1">
77+
<CircleUserRound size={14} /> {author}
78+
</p>
79+
<p className="flex items-center gap-1">
80+
<Clock size={14} /> {readTime || defaultReadTime}
81+
</p>
82+
</div>
83+
</div>
84+
</Link>
85+
)
86+
}
87+
1788
export default async function BlogPage() {
1889
return (
1990
<main className="mt-[80px]">
@@ -27,6 +98,21 @@ export default async function BlogPage() {
2798
</section>
2899

29100
<section className="mx-auto mb-20 flex max-w-7xl flex-col">
101+
<hr className="border-dashed border-neutral-100/15" />
102+
<div className="grid grid-cols-1 md:grid-cols-3">
103+
{allBlogs
104+
.filter((post) => post.isFeatured)
105+
.map((post, index) => (
106+
<BlogCard key={index} {...post} index={index} />
107+
))}
108+
</div>
109+
<div className="mb-12 mt-20 text-center">
110+
<h2 className="text-xl font-bold tracking-tight md:text-4xl">
111+
<span className="bg-gradient-to-b from-neutral-700 to-neutral-200 bg-clip-text text-transparent">
112+
All Blogs
113+
</span>
114+
</h2>
115+
</div>
30116
<hr className="border-dashed border-neutral-100/15" />
31117
{allBlogs.map((post) => (
32118
<Link

src/components/FeaturedPosts.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import { CircleUserRound, Clock } from "lucide-react"
88
import { cn } from "@/lib/utils"
99
import { allBlogs } from "@/app/blog/data"
1010

11-
const featuredPosts = allBlogs.filter((post) => post.isFeatured)
12-
1311
interface BlogCardProps {
1412
index: number
1513
title: string
@@ -84,11 +82,11 @@ const FeaturedPosts: React.FC = () => {
8482
<div className="mx-auto max-w-7xl py-20 text-center">
8583
<h2 className="mb-6 text-3xl font-bold tracking-tight md:text-5xl">
8684
<span className="bg-gradient-to-b from-neutral-600 to-neutral-200 bg-clip-text text-transparent">
87-
Featured Posts
85+
Recent Posts
8886
</span>
8987
</h2>
9088
<p className="text-lg text-neutral-400 md:text-xl">
91-
Our most trending blog posts.
89+
Our most recent blog posts.
9290
</p>
9391
</div>
9492

@@ -97,7 +95,7 @@ const FeaturedPosts: React.FC = () => {
9795
</div>
9896
<div className="mx-auto max-w-7xl">
9997
<div className="grid grid-cols-1 md:grid-cols-3">
100-
{featuredPosts.slice(0, 3).map((post, index) => (
98+
{allBlogs.slice(0, 3).map((post, index) => (
10199
<BlogCard key={index} {...post} index={index} />
102100
))}
103101
</div>

0 commit comments

Comments
 (0)