hello this is eomtgin
4 MIN READ•5/7/2026
ehjello the lviei preive will apear hear
and let get back to work now what to d
'use client';
import { useState, useEffect } from 'react';
cxvxcvxvbxbvxbxcbxcbxcbxc
export default function NewPostPage() {
const [form, setForm] = useState({
title: '',
description: '',
content: '',
category: '',
tags: '',
published: false
});
const [loading, setLoading] = useState(false);
const [error, setError] = useState('');
const [previewHtml, setPreviewHtml] = useState('');
// Live Real-Time Rendering
useEffect(() => {
const timer = setTimeout(async () => {
if (!form.content) {
setPreviewHtml('');
return;
}
try {
const res = await fetch('/api/preview', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content: form.content })
});
if (res.ok) {
const data = await res.json();
setPreviewHtml(data.html);
}
} catch (e) {}
}, 300);
return () => clearTimeout(timer);
}, [form.content]);
// Prevent pasting files before the post exists
const handlePasteOrDrop = (e: any) => {
const files = e.clipboardData?.files || e.dataTransfer?.files;
if (files && files.length > 0) {
e.preventDefault();
alert(
'SYSTEM LOCK: You must click "INITIALIZE SIGNAL" on the right before you can upload or paste files!'
);
}
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setLoading(true);
setError('');
try {
const res = await fetch('/api/posts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
...form,
published: form.published ? 1 : 0
})
});
if (res.ok) {
window.location.href = '/admin';
} else {
const data = await res.json().catch(() => ({}));
setError(
data.error || 'Initialization Failed. Check title uniqueness.'
);
}
} catch (err) {
setError('System network failure.');
} finally {
setLoading(false);
}
};
return (
← Abort
/ Initialize_New