v1.13.1-data: links/redirects, captions, partner picks, Plausible reports, migration baseline #28

Merged
ngu-git-admin merged 16 commits from data into main 2026-10-06 10:10:57 +01:00
2 changed files with 28 additions and 2 deletions
Showing only changes of commit 0eea9ba13b - Show all commits

View file

@ -5,7 +5,7 @@
/go/<URL ID>, and passed on with the link's UTM tags. Server side:
server/src/admin-schema/redirects.js and routes/redirects.js. */
import { SITE_ORIGIN } from "../site.ts";
import { SITE_ORIGIN, siteUrl } from "../site.ts";
const GO = `${SITE_ORIGIN.replace(/^https?:\/\//, "").replace(/\/$/, "")}/go/`;
@ -15,6 +15,8 @@ export const redirects = {
singular: "redirect",
idLabel: "URL ID",
idPrefix: GO,
// The address to share, copied from the saved redirect's page.
idLink: (id: string) => siteUrl(`/go/${id}`),
list: {
columns: [

View file

@ -46,7 +46,7 @@
why the array form exists and teams uses it.
═══════════════════════════════════════════════════════════════ */
import { ArrowLeft } from "@phosphor-icons/react";
import { ArrowLeft, Check, Copy } from "@phosphor-icons/react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useLocation, useNavigate, useParams } from "react-router-dom";
@ -450,6 +450,7 @@ export default function EntityEdit() {
change("id", `${prefixOf(form)}${slugify(value)}`);
}}
/>
{!isNew && manifest.idLink && <CopyLink url={manifest.idLink(form.id)} />}
{!isNew && form.updated_at && (
<p className="mt-2 text-xs text-muted">
Last saved {form.updated_at}
@ -649,3 +650,26 @@ function RequestedChanges({ request, isNew, form, onUse, onAdd }: any) {
);
}
/* A saved record's own link (the manifest's `idLink`, eg. a redirect's
/go/ address), with a button to copy it. */
function CopyLink({ url }: { url: string }) {
const [copied, setCopied] = useState(false);
return (
<div className="mt-3 flex flex-wrap items-center gap-3">
<code className="break-all text-sm text-body">{url}</code>
<button
type="button"
onClick={() =>
navigator.clipboard?.writeText(url).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 1500);
})
}
className="btn inline-flex items-center gap-1.5 border border-link px-3 py-1 text-sm text-link transition-colors hover:bg-tint"
>
{copied ? <Check weight="bold" aria-hidden="true" /> : <Copy weight="bold" aria-hidden="true" />}
{copied ? "Copied" : "Copy link"}
</button>
</div>
);
}