Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/a/[slug]/BlogPostClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ArrowLeft, Calendar, User } from "lucide-react"
import Image from "next/image"
import { MarkdownRenderer } from "@/lib/markdown-renderer"
import Footer from "@/components/footer"
import { BlogPost } from "@/lib/blog"
import type { BlogPost } from "@/types/blog"

export default function BlogPostPage({ post }: { post: BlogPost }) {
const [copied, setCopied] = useState(false)
Expand Down
20 changes: 2 additions & 18 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,12 @@ import BlogCard from "@/components/blog-card"
import Pagination from "@/components/pagination"
import Link from "next/link"
import Footer from "@/components/footer"

interface BlogPost {
slug: string
title: string
author: string
date: string
image: string
excerpt: string
featured: boolean
}

interface PaginatedData {
posts: BlogPost[]
totalPages: number
hasNextPage: boolean
hasPrevPage: boolean
}
import type { PaginatedPosts } from "@/types/blog"

export default function HomePage() {
const router = useRouter()
const searchParams = useSearchParams()
const [paginatedData, setPaginatedData] = useState<PaginatedData | null>(null)
const [paginatedData, setPaginatedData] = useState<PaginatedPosts | null>(null)
const [loading, setLoading] = useState(true)
const [currentPage, setCurrentPage] = useState(1)

Expand Down
11 changes: 1 addition & 10 deletions components/blog-card.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import Image from "next/image"
import Link from "next/link"
import { User, Star } from "lucide-react"

interface BlogPost {
slug: string
title: string
author: string
date: string
image: string
excerpt: string
featured: boolean
}
import type { BlogPost } from "@/types/blog"

interface BlogCardProps {
post: BlogPost
Expand Down
12 changes: 1 addition & 11 deletions lib/blog-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@ import { readFileSync, existsSync } from 'fs'
import { join } from 'path'
import matter from 'gray-matter'
import articlesIndex from '../public/articles/articles-index.json'

export interface BlogPost {
slug: string
title: string
author: string
date: string
image: string
excerpt: string
content: string
featured: boolean
}
import type { BlogPost } from '@/types/blog'

// Server-side function to get post by slug with actual markdown content
export function getPostBySlugServer(slug: string): BlogPost | null {
Expand Down
20 changes: 2 additions & 18 deletions lib/blog.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import articlesIndex from '../public/articles/articles-index.json'

export interface BlogPost {
slug: string
title: string
author: string
date: string
image: string
excerpt: string
content: string
featured: boolean
}
import type { BlogPost, PaginatedPosts } from '@/types/blog'

// Get all posts from articles index (client-safe)
export function getAllPosts(): BlogPost[] {
Expand Down Expand Up @@ -39,13 +29,7 @@ export function getPostBySlug(slug: string): BlogPost | null {
export function getPaginatedPosts(
page = 1,
limit = 6,
): {
posts: BlogPost[]
totalPages: number
currentPage: number
hasNextPage: boolean
hasPrevPage: boolean
} {
): PaginatedPosts {
const allPosts = getAllPosts()
const totalPosts = allPosts.length
const totalPages = Math.ceil(totalPosts / limit)
Expand Down
18 changes: 18 additions & 0 deletions types/blog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export interface BlogPost {
slug: string
title: string
author: string
date: string
image: string
excerpt: string
content: string
featured: boolean
}

export interface PaginatedPosts {
posts: BlogPost[]
totalPages: number
currentPage: number
hasNextPage: boolean
hasPrevPage: boolean
}