Skip to content

Commit 719e1f9

Browse files
committed
fix issue in recent posts
Signed-off-by: Amrish Kushwaha <askmaurya48@gmail.com>
1 parent d8d8f29 commit 719e1f9

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

content/blog/2025-07-06--ui-aspects.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
2-
title: "UI Aspects"
2+
title: "UI Aspects (Living blog)"
33
date: "2025-07-06"
44
category: "production-ready"
5+
tags: ["UI Aspects", "Production Ready"]
56
---
67

7-
# All About UI Aspects (Living Document)
8+
# All About UI Aspects
89

910
## 🧱 1. Architecture & Design System
1011
- Use Atomic Design principles (atoms → molecules → organisms)

src/components/RecentPosts/index.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ChevronRight } from "react-feather";
33
import { Card } from "../Card";
44
import Link from "next/link";
55
import { usePosts } from "../../graphql/allPostsQuery";
6+
import { getAllBlogsMetadata, BlogMetadata } from "../../../lib/blogs";
67

78
interface Post {
89
title: string;
@@ -14,13 +15,38 @@ interface Post {
1415
excerpt?: string;
1516
}
1617

18+
// Convert BlogMetadata to Post format for consistency
19+
function convertBlogToPost(blog: BlogMetadata): Post {
20+
return {
21+
title: blog.title,
22+
date: blog.date,
23+
tags: blog.tags || [],
24+
featured_image: "", // MDX posts don't have featured images
25+
excerpt: `Recent blog post in category: ${blog.category}`,
26+
slug: `/blog/${blog.slug}`,
27+
};
28+
}
29+
1730
export const RecentPosts = () => {
18-
const posts: Post[] = usePosts(3);
31+
const jsonPosts: Post[] = usePosts(3);
32+
33+
// Get MDX blog posts
34+
const mdxBlogs = getAllBlogsMetadata();
35+
const mdxPosts = mdxBlogs.map(convertBlogToPost);
36+
37+
// Combine and sort all posts by date
38+
const allPosts = [...mdxPosts, ...jsonPosts].sort(
39+
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
40+
);
41+
42+
// Take the 3 most recent posts
43+
const recentPosts = allPosts.slice(0, 3);
44+
1945
return (
2046
<div className="mt-12 mb-8">
2147
<h2 className="text-2xl font-bold mb-6 text-foreground">Recent Posts:</h2>
2248
<div className="flex flex-col gap-6">
23-
{posts.map((res: Post) => {
49+
{recentPosts.map((res: Post) => {
2450
return <Card {...res} key={res.title} />;
2551
})}
2652
</div>

0 commit comments

Comments
 (0)