feat: implement EditPost page with functionality to update existing blog posts
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 17s

This commit is contained in:
2025-10-26 18:21:45 +08:00
parent 085e48ff69
commit 1f6bb77691
8 changed files with 566 additions and 56 deletions

View File

@@ -1,16 +1,18 @@
import { useState, useRef } from 'react';
import { useNavigate } from 'react-router-dom';
import { Navigate, useNavigate } from 'react-router-dom';
import Layout from '../components/Layout';
import BlogEditor, { type BlogEditorRef } from '../blog/BlogEditor';
import { uploadImage, createBlogPost } from '../blog/api';
import { Toast } from '../components/Toast';
import { useToast } from '../hooks/useToast';
import { useAuth } from '../contexts/AuthContext';
import '../App.css';
function CreatePost() {
const navigate = useNavigate();
const editorRef = useRef<BlogEditorRef>(null);
const { toasts, removeToast, success, error } = useToast();
const { isAuthenticated } = useAuth();
const [title, setTitle] = useState('');
const [coverImage, setCoverImage] = useState<string | null>(null);
const [coverImageKey, setCoverImageKey] = useState<string>('');
@@ -99,6 +101,10 @@ function CreatePost() {
}
};
if (!isAuthenticated) {
return <Navigate to="/blog" replace />;
}
return (
<Layout currentPage="blog">
<Toast toasts={toasts} onRemove={removeToast} />