flatten monorepo, migrate off Vercel
- Remove penfield (split to own repo on Forgejo) - Move www/ contents to root, rename to wynne.rs - Swap @astrojs/vercel for @astrojs/node, upgrade to Astro 6 - Remove auth-astro/GitHub OAuth (TinyAuth at proxy layer) - Remove Vercel deploy webhook - Switch to local SQLite DB (drop Turso) - Update generate-stats.js for new build output paths
This commit is contained in:
parent
f2acf36784
commit
8a9c56c3d5
52 changed files with 45 additions and 7135 deletions
43
src/scripts/guestbook-sign.ts
Normal file
43
src/scripts/guestbook-sign.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
export function initGuestbookForm() {
|
||||
const form = document.getElementById('guestbook-form') as HTMLFormElement | null;
|
||||
if (!form) return;
|
||||
|
||||
const status = document.getElementById('guestbook-status')!;
|
||||
|
||||
form.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
status.textContent = '';
|
||||
|
||||
const data = new FormData(form);
|
||||
const name = (data.get('name') as string).trim();
|
||||
const message = (data.get('message') as string).trim();
|
||||
const url = (data.get('url') as string).trim() || null;
|
||||
|
||||
if (!name || !message) return;
|
||||
|
||||
const button = form.querySelector('button')!;
|
||||
button.disabled = true;
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/guestbook', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name, message, url }),
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
status.textContent = ' thanks! pending approval.';
|
||||
form.reset();
|
||||
} else if (res.status === 429) {
|
||||
status.textContent = ' too many requests, try later.';
|
||||
} else {
|
||||
const body = await res.json().catch(() => null);
|
||||
status.textContent = body?.error ? ` ${body.error}` : ' error';
|
||||
}
|
||||
} catch {
|
||||
status.textContent = ' failed';
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue