forked from UKSOURCE/hailearning.edu.vn
feat: Refactor blog components and add pagination
This commit is contained in:
136
types/blog.ts
Normal file
136
types/blog.ts
Normal 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;
|
||||
}
|
||||
4
types/index.ts
Normal file
4
types/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Export all types
|
||||
*/
|
||||
export * from './blog';
|
||||
Reference in New Issue
Block a user