Newsletter: Pick a redirect on every link field

Link fields with redirects: true get a list of Data > Links/redirects that fills in the short link's full address; the newsletter turns it on for its blocks' links and their items' links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-05 00:39:52 -05:00
parent 6289e7203f
commit e060153798
3 changed files with 41 additions and 3 deletions

View file

@ -62,6 +62,10 @@
the file's name and first-page preview. `filesWhen` limits it to
rows that match, as `when` does for the field.
`redirects: true` on a link field adds "Pick a redirect": a list of
Data → Links/redirects (the `redirects` options) that fills the
field with the short link's full address, <site>/go/<URL ID>.
`widget: "testNotice"` is a text box of email addresses with a
"Send a test notice" button (TestNoticeInput below), for Site
settings → Notices.
@ -97,6 +101,7 @@ import ContentBlocks from "../ContentBlocks.tsx";
import { FILTER_FROM, OptionFilter, narrow } from "../OptionFilter.tsx";
import { ImageInput, LinkPreviewInput } from "./MediaLibrary.tsx";
import { ChooseFileButton } from "./DriveFiles.tsx";
import { siteUrl } from "../../lib/site.ts";
/* Live previews a collection can name with `preview`. Each gets the
row as the form holds it, which is the API's shape. */
@ -434,6 +439,21 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
<ChooseFileButton value={value} onPick={pickFile} />
</div>
)}
{field.redirects && !locked && options?.redirects?.length > 0 && (
<select
value=""
onChange={(e) => e.target.value && onChange(siteUrl(`/go/${e.target.value}`))}
aria-label={`${typeof field.label === "function" ? field.label(row) : field.label}: pick a redirect`}
className={`mt-2 ${common.className}`}
>
<option value="">Pick a redirect (Data → Links/redirects)</option>
{options.redirects.map((option) => (
<option key={option.id} value={option.id}>
{option.label}
</option>
))}
</select>
)}
</div>
{error ? (