Skip to content

Commit ec61539

Browse files
committed
Merge branch 'main' into refactor/animated-loading-spinner
# Conflicts: # app/page.tsx
2 parents af0a57f + 84bdd4d commit ec61539

6 files changed

Lines changed: 25 additions & 57 deletions

File tree

app/a/[slug]/BlogPostClient.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ArrowLeft, Calendar, User } from "lucide-react"
66
import Image from "next/image"
77
import { MarkdownRenderer } from "@/lib/markdown-renderer"
88
import Footer from "@/components/footer"
9-
import { BlogPost } from "@/lib/blog"
9+
import type { BlogPost } from "@/types/blog"
1010

1111
export default function BlogPostPage({ post }: { post: BlogPost }) {
1212
const [copied, setCopied] = useState(false)

app/page.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,12 @@ import Pagination from "@/components/pagination"
88
import Link from "next/link"
99
import Footer from "@/components/footer"
1010
import Loading from "@/app/loading"
11-
interface BlogPost {
12-
slug: string
13-
title: string
14-
author: string
15-
date: string
16-
image: string
17-
excerpt: string
18-
featured: boolean
19-
}
20-
21-
interface PaginatedData {
22-
posts: BlogPost[]
23-
totalPages: number
24-
hasNextPage: boolean
25-
hasPrevPage: boolean
26-
}
11+
import type { PaginatedPosts } from "@/types/blog"
2712

2813
export default function HomePage() {
2914
const router = useRouter()
3015
const searchParams = useSearchParams()
31-
const [paginatedData, setPaginatedData] = useState<PaginatedData | null>(null)
16+
const [paginatedData, setPaginatedData] = useState<PaginatedPosts | null>(null)
3217
const [loading, setLoading] = useState(true)
3318
const [currentPage, setCurrentPage] = useState(1)
3419

components/blog-card.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
import Image from "next/image"
22
import Link from "next/link"
33
import { User, Star } from "lucide-react"
4-
5-
interface BlogPost {
6-
slug: string
7-
title: string
8-
author: string
9-
date: string
10-
image: string
11-
excerpt: string
12-
featured: boolean
13-
}
4+
import type { BlogPost } from "@/types/blog"
145

156
interface BlogCardProps {
167
post: BlogPost

lib/blog-server.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@ import { readFileSync, existsSync } from 'fs'
22
import { join } from 'path'
33
import matter from 'gray-matter'
44
import articlesIndex from '../public/articles/articles-index.json'
5-
6-
export interface BlogPost {
7-
slug: string
8-
title: string
9-
author: string
10-
date: string
11-
image: string
12-
excerpt: string
13-
content: string
14-
featured: boolean
15-
}
5+
import type { BlogPost } from '@/types/blog'
166

177
// Server-side function to get post by slug with actual markdown content
188
export function getPostBySlugServer(slug: string): BlogPost | null {

lib/blog.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
import articlesIndex from '../public/articles/articles-index.json'
2-
3-
export interface BlogPost {
4-
slug: string
5-
title: string
6-
author: string
7-
date: string
8-
image: string
9-
excerpt: string
10-
content: string
11-
featured: boolean
12-
}
2+
import type { BlogPost, PaginatedPosts } from '@/types/blog'
133

144
// Get all posts from articles index (client-safe)
155
export function getAllPosts(): BlogPost[] {
@@ -39,13 +29,7 @@ export function getPostBySlug(slug: string): BlogPost | null {
3929
export function getPaginatedPosts(
4030
page = 1,
4131
limit = 6,
42-
): {
43-
posts: BlogPost[]
44-
totalPages: number
45-
currentPage: number
46-
hasNextPage: boolean
47-
hasPrevPage: boolean
48-
} {
32+
): PaginatedPosts {
4933
const allPosts = getAllPosts()
5034
const totalPosts = allPosts.length
5135
const totalPages = Math.ceil(totalPosts / limit)

types/blog.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export interface BlogPost {
2+
slug: string
3+
title: string
4+
author: string
5+
date: string
6+
image: string
7+
excerpt: string
8+
content: string
9+
featured: boolean
10+
}
11+
12+
export interface PaginatedPosts {
13+
posts: BlogPost[]
14+
totalPages: number
15+
currentPage: number
16+
hasNextPage: boolean
17+
hasPrevPage: boolean
18+
}

0 commit comments

Comments
 (0)