fix(rvote): serve demo at demo.rspace.online/rvote instead of /rvote/demo

Extract demo body into renderDemoBody(), serve it from the / route when
space=demo (which is what demo.rspace.online/rvote resolves to via
subdomain routing). Legacy /demo path now 301-redirects to the canonical
demo.rspace.online/rvote URL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-03-20 16:29:26 -07:00
parent 05459ec8a9
commit 8d8ae7e351
1 changed files with 26 additions and 15 deletions

View File

@ -506,17 +506,10 @@ routes.post("/api/proposals/:id/final-vote", async (c) => {
return c.json({ ok: true, tally });
});
// ── Page routes ──
// ── Demo page body (reused by / when space=demo, and /demo fallback) ──
// Demo page — interactive polls with live sync
routes.get("/demo", (c) => {
return c.html(renderShell({
title: "rVote Demo — Interactive Polls | rSpace",
moduleId: "rvote",
spaceSlug: "demo",
modules: getModuleInfoList(),
theme: "dark",
body: `
function renderDemoBody(): string {
return `
<div class="rd-page">
<div class="rd-hero">
<span class="rl-badge" style="background:#1e293b;color:#94a3b8;font-size:0.7rem;padding:0.25rem 0.75rem;display:inline-block;margin-bottom:0.75rem;border-radius:9999px">Interactive Demo</span>
@ -635,15 +628,33 @@ routes.get("/demo", (c) => {
<div class="rd-footer">
<a href="/rvote">&larr; Back to rVote</a>
</div>
</div>`,
scripts: `<script type="module" src="/modules/rvote/vote-demo.js"></script>`,
styles: `<link rel="stylesheet" href="/modules/rvote/vote.css">`,
}));
</div>`;
}
// ── Page routes ──
// Legacy /demo path — redirect to demo.rspace.online/rvote
routes.get("/demo", (c) => {
return c.redirect("https://demo.rspace.online/rvote", 301);
});
// Dashboard — full voting app with spaces, proposals, conviction voting
// Main route — serves demo page when space=demo, dashboard otherwise
routes.get("/", (c) => {
const space = c.req.param("space") || "demo";
if (space === "demo") {
return c.html(renderShell({
title: "rVote Demo — Interactive Polls | rSpace",
moduleId: "rvote",
spaceSlug: "demo",
modules: getModuleInfoList(),
theme: "dark",
body: renderDemoBody(),
scripts: `<script type="module" src="/modules/rvote/vote-demo.js"></script>`,
styles: `<link rel="stylesheet" href="/modules/rvote/vote.css">`,
}));
}
return c.html(renderShell({
title: `${space} — Vote | rSpace`,
moduleId: "rvote",