function LoginPage({ onGo, onAuth }) { const [user, setUser] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [msg, setMsg] = useState(null); async function handleSubmit(e) { e.preventDefault(); setMsg(null); setLoading(true); try { const res = await fetch('/api/admin-login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user, password }) }); const data = await res.json(); if (!res.ok) throw new Error(data.error || 'Login failed'); window.setAdminToken(data.token); onAuth?.(); onGo('publish'); } catch (err) { console.error(err); setMsg({ type: 'error', text: err.message || 'Login failed' }); } finally { setLoading(false); } } return (

Admin login

Sign in to access the publish admin page.

setUser(e.target.value)} style={{width: '100%', padding: 12, marginBottom: 12}} /> setPassword(e.target.value)} style={{width: '100%', padding: 12, marginBottom: 12}} />
{msg &&
{msg.text}
}
); } window.LoginPage = LoginPage; function PublishPage({ onGo }) { const [title, setTitle] = useState(''); const [content, setContent] = useState(''); const [loading, setLoading] = useState(false); const [msg, setMsg] = useState(null); async function handleSubmit(e) { e.preventDefault(); setMsg(null); setLoading(true); try { // default proxy path assumes Vercel deployment at project root const res = await publishViaProxy({ title, content }, '/api/publish'); setMsg({ type: 'success', text: `Published (ID ${res.id})` }); setTitle(''); setContent(''); } catch (err) { console.error(err); setMsg({ type: 'error', text: err.message || 'Publish failed' }); } finally { setLoading(false); } } return (

Publish (Admin)

This form posts to `/api/publish` and requires an admin session token.

setTitle(e.target.value)} style={{width: '100%', padding: 12, marginBottom: 12}} />