feat: Refactor blog components and add pagination

This commit is contained in:
Wini_Fy
2026-02-03 17:05:09 +07:00
parent bf652a64b6
commit 29cc0bf2cd
27 changed files with 2051 additions and 429 deletions

136
types/blog.ts Normal file
View File

@@ -0,0 +1,136 @@
/**
* Blog Types
* Định nghĩa các interface cho Blog system
*/
export interface BlogCategory {
_id?: string;
name: string;
slug: string;
description?: string;
postCount?: number;
isActive?: boolean;
createdAt?: string;
updatedAt?: string;
}
export interface BlogTag {
_id?: string;
name: string;
slug: string;
postCount?: number;
isActive?: boolean;
createdAt?: string;
updatedAt?: string;
}
export interface BlogComment {
_id?: string;
postId?: string;
authorName: string;
authorAvatar?: string;
content: string;
createdAt: string;
status?: 'pending' | 'approved' | 'rejected';
parentId?: string;
parentAuthorName?: string | null;
}
export interface BlogPost {
_id?: string;
title: string;
slug: string;
excerpt: string;
content: string;
category: string[];
tags: string[];
author: string;
status: 'draft' | 'published';
publishedAt: string;
isFeatured: boolean;
featuredImage: string;
galleryImages?: string[];
quote?: string;
contentAfterQuote?: string;
commentsCount: number;
comments?: BlogComment[];
createdAt?: string;
updatedAt?: string;
}
export interface RecentPost {
_id?: string;
title: string;
slug: string;
thumbnail: string;
publishedAt: string;
originalPostId?: string;
createdAt?: string;
updatedAt?: string;
}
export interface BlogPagination {
current: number;
total: number;
limit: number;
totalItems: number;
}
export interface BlogListResponse {
success: boolean;
message: string;
data: {
blogs: BlogPost[];
pagination: BlogPagination;
};
}
export interface BlogDetailResponse {
success: boolean;
message: string;
data: BlogPost;
}
export interface BlogFeaturedResponse {
success: boolean;
message: string;
data: BlogPost[];
}
export interface BlogRecentResponse {
success: boolean;
message: string;
data: RecentPost[];
}
export interface CategoryListResponse {
success: boolean;
message: string;
data: BlogCategory[];
}
export interface CategoryDetailResponse {
success: boolean;
message: string;
data: BlogCategory;
}
export interface TagListResponse {
success: boolean;
message: string;
data: BlogTag[];
}
export interface TagDetailResponse {
success: boolean;
message: string;
data: BlogTag;
}
export interface BlogQueryParams {
page?: number;
limit?: number;
category?: string;
tag?: string;
search?: string;
}