NGU-Web/server/src/admin-schema/redirects.js
Zaldimmar 6289e7203f Links/redirects: /go/ short links with click counts, Plausible and UTM tags (migration 068)
Data > Links/redirects (editors and up) makes short links on our
domain. GET /go/<id> counts the click, reports it to Plausible as a
pageview of /go/<id> (the visitor's browser and address, no key
needed), and redirects (302, no-store) with the link's UTM tags added
to the destination. Unknown ids fall through to the not-found page.
The editor can show a fixed lead-in in the URL ID box (idPrefix).
Vite proxies /go in dev. docs/redirects.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 00:37:26 -05:00

30 lines
805 B
JavaScript

import { text, url } from "./columns.js";
/* ── Links/redirects (068_redirects.sql) ─────────────────────────
Short links on our domain, /go/<id>, answered by
routes/redirects.js. clicks and last_clicked_at are the route's,
so they're listed but never written from here: a save can't reset
a count. */
export const redirects = {
key: "redirects",
table: "redirects",
idColumn: "id",
idKind: "slug",
list: {
columns: ["id", "target_url", "clicks", "last_clicked_at"],
filters: [],
search: ["id", "target_url", "note", "utm_campaign"],
order: "id",
},
columns: [
url("target_url", { required: true }),
text("note"),
text("utm_source"),
text("utm_medium"),
text("utm_campaign"),
],
};