feat: Implement blog and blog post models, routes, and services
- Added Blog and BlogPost models with necessary fields and relationships. - Created blogRouter for handling blog-related API endpoints including CRUD operations. - Developed BlogService for business logic related to blogs and posts, including sharing functionality. - Implemented API client methods for frontend to interact with blog-related endpoints. - Added internationalization support for blog-related text in English and German. - Created Vue components for blog editing, listing, and viewing, including a rich text editor for post content. - Enhanced user experience with form validations and dynamic visibility settings based on user input.
This commit is contained in:
19
frontend/src/api/blogApi.js
Normal file
19
frontend/src/api/blogApi.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import apiClient from '@/utils/axios.js';
|
||||
|
||||
export const listBlogs = async () => (await apiClient.get('/api/blog/blogs')).data;
|
||||
export const getBlog = async (id) => (await apiClient.get(`/api/blog/blogs/${id}`)).data;
|
||||
export const listPosts = async (id, { page = 1, pageSize = 10 } = {}) => (await apiClient.get(`/api/blog/blogs/${id}/posts`, { params: { page, pageSize } })).data;
|
||||
|
||||
export const createBlog = async (payload) => (await apiClient.post('/api/blog/blogs', payload)).data;
|
||||
export const updateBlog = async (id, payload) => (await apiClient.put(`/api/blog/blogs/${id}`, payload)).data;
|
||||
export const createPost = async (id, payload) => (await apiClient.post(`/api/blog/blogs/${id}/posts`, payload)).data;
|
||||
export const listBlogImages = async (id) => (await apiClient.get(`/api/blog/blogs/${id}/images`)).data;
|
||||
export const uploadBlogImage = async (id, file, meta = {}) => {
|
||||
const formData = new FormData();
|
||||
formData.append('image', file);
|
||||
if (meta.title) formData.append('title', meta.title);
|
||||
if (meta.description) formData.append('description', meta.description);
|
||||
return (await apiClient.post(`/api/blog/blogs/${id}/images`, formData, { headers: { 'Content-Type': 'multipart/form-data' } })).data;
|
||||
};
|
||||
export const shareBlog = async (id, payload) => (await apiClient.post(`/api/blog/blogs/${id}/share`, payload)).data;
|
||||
|
||||
Reference in New Issue
Block a user