Blog Management
Overview
This skill helps you work with blog post management features in the admin_side application. It includes creating new posts, editing existing posts, managing tags, handling thumbnails, and working with the Quill rich text editor.
Key Files and Components
Blog Pages
- •
src/app/admin/blogs/page.tsx- Blog listing page - •
src/app/admin/blogs/create/page.tsx- Create new blog page - •
src/app/admin/blogs/edit/page.tsx- Edit existing blog page - •
src/app/admin/blogs/blog-form.tsx- Main blog form component
Related Components
- •
src/app/admin/components/inputs/rich-text-editor/- Quill editor components - •
src/app/admin/components/inputs/multi-chip-input.tsx- Tag input component - •
src/app/admin/components/inputs/thumbnail-input.tsx- Image upload component
Domain Models
- •
src/domains/post.ts- Blog post model and types - •
src/domains/tag.ts- Tag model and types
Common Tasks
Working with Blog Posts
When creating or editing blog posts:
- •
Read the blog form to understand the current structure:
bashRead src/app/admin/blogs/blog-form.tsx
- •
Check the post domain model for data structure:
bashRead src/domains/post.ts
- •
Review API integration in
src/config/api.config.ts
Blog Post Fields
A blog post typically includes:
- •title: Post title
- •previewContent: Short preview/excerpt
- •content: Full HTML content from Quill editor
- •thumbnailPaths: Array of image URLs
- •published: Boolean status (draft/published)
- •postTags: Array of tags with name and color
- •categoryId: Selected category ID
- •rowVersion: For optimistic locking
Rich Text Editor
The project uses Quill 2.0 with plugins:
- •quill-html-edit-button
- •quill-resize-image
- •quill-table-better
- •quill-toggle-fullscreen-button
- •highlight.js for code syntax
When working with the editor:
- •Check
RichTextEditorWrappercomponent for setup - •Verify plugin initialization
- •Test content saving and loading
Tag Management
Tags use the MultiChipInput component with:
- •Random color assignment
- •Add/remove functionality
- •Label-based storage
Thumbnail Management
Images are handled by ThumbnailsInput:
- •Accepts image uploads
- •Returns array of paths
- •Displays preview thumbnails
API Endpoints
Blog posts use REST API endpoints:
- •
GET /posts- List all posts - •
GET /posts/:id- Get single post - •
POST /posts- Create new post - •
PUT /posts/:id- Update existing post - •
DELETE /posts/:id- Delete post
All endpoints require Bearer token authentication via authenticatedFetch.
Best Practices
- •Always validate data before submission
- •Handle loading states with appropriate UI feedback
- •Preserve rowVersion for optimistic locking on updates
- •Test rich text content for proper HTML rendering
- •Check authentication before API calls
- •Handle errors gracefully with user-friendly messages
- •Use TypeScript types from domain models
Debugging Tips
If you encounter issues:
- •Check browser console for API errors
- •Verify authentication token is valid
- •Check network tab for failed requests
- •Validate form data matches API expectations
- •Test Quill editor initialization
- •Verify image upload paths are correct
Example Workflow
When implementing a new blog feature:
- •Read relevant domain model
- •Review existing blog-form.tsx implementation
- •Check API configuration
- •Test with existing data
- •Implement changes following established patterns
- •Validate with TypeScript
- •Test in development server