mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 19:16:24 +00:00
⚡️ feat: add post fetching by ID and improve blog home page
- Implemented `getPostById` API function to fetch a post by its ID. - Refactored the main page to use a new `BlogHome` component for better organization. - Added loading state and sorting functionality for posts on the blog home page. - Integrated label fetching and display on the blog home page. - Enhanced the blog card component with improved layout and statistics display. - Updated the navbar to use dynamic configuration values. - Added Docker support with a comprehensive build and push workflow. - Created a custom hook `useStoredState` for managing local storage state. - Added a new page for displaying individual posts with metadata generation. - Removed unused components and files to streamline the codebase.
This commit is contained in:
10
web/src/api/label.ts
Normal file
10
web/src/api/label.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import type { Label } from "@/models/label";
|
||||
import type { BaseResponse } from "@/models/resp";
|
||||
import axiosClient from "./client";
|
||||
|
||||
|
||||
export async function listLabels(): Promise<BaseResponse<Label[]>> {
|
||||
const res = await axiosClient.get<BaseResponse<Label[]>>("/label/list", {
|
||||
});
|
||||
return res.data;
|
||||
}
|
@ -10,6 +10,16 @@ interface ListPostsParams {
|
||||
keywords?: string;
|
||||
}
|
||||
|
||||
export async function getPostById(id: string): Promise<Post | null> {
|
||||
try {
|
||||
const res = await axiosClient.get<BaseResponse<Post>>(`/post/p/${id}`);
|
||||
return res.data.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching post by ID:", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function listPosts({
|
||||
page = 1,
|
||||
size = 10,
|
||||
|
Reference in New Issue
Block a user