Theme switcher, table of contents, missing-page redirect, form placeholders and time field; audit and revalidate fixes
- buildRevalidateHook skips outside Next (no NEXT_RUNTIME) and with context.disableRevalidate - BuilderForm focuses only on a real step change (no scroll to the form on remount) - mediaImageProps: placeholder colour only for JPEG (placeholderColor); hook stores no colour for transparent images - buildLinkField: interface name per shape (CmsLink, CmsLinkPlain, CmsLinkNoLabel) + interfaceName option - Cookie Settings: buttons.save -> buttons.savePreferences (Mongoose reserved name) - ThemeScript, ThemeSwitcher, useTheme; Site Settings defaultTheme 'system' + themeToggleLabel; Turnstile follows page theme - extractHeadings, RenderRichText headingIds, TableOfContents, buildTableOfContentsField - createPageRoute onMissing: 'redirectHome' - Form builder: localized placeholder on text/email/textarea/number, new time field - ipal-audit: no false positive for object keys between JSX elements; /md route not reported as dynamic Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
23e033d7d7
commit
faa4ad679c
@@ -17,6 +17,14 @@ export type BuildLinkFieldOptions = {
|
||||
appearances?: false | readonly LinkAppearanceOption[]
|
||||
/** Hide the label — for links that wrap something (a whole card, an image). */
|
||||
disableLabel?: boolean
|
||||
/**
|
||||
* Name of the generated TypeScript type. Default depends on the shape, so links of
|
||||
* different shapes never share one name (payload generate:types would keep only the
|
||||
* last one processed): `CmsLink`, `CmsLinkPlain` (appearances: false),
|
||||
* `CmsLinkNoLabel` (disableLabel), `CmsLinkPlainNoLabel` (both). Set it yourself
|
||||
* when you mix different `appearances` lists or `relationTo` values.
|
||||
*/
|
||||
interfaceName?: string
|
||||
/** Field name. Default 'link'. */
|
||||
name?: string
|
||||
/** Collection the "Page" option points at. Default 'pages'. */
|
||||
@@ -37,7 +45,8 @@ type SiblingWithType = { type?: string } | undefined
|
||||
* there is no zoo of ctaLabel / buttonUrl / pdfUrl fields and one renderer
|
||||
* (resolveLinkHref + the project's CMSLink) handles them all.
|
||||
*
|
||||
* Generates a named TypeScript type `CmsLink` in payload-types.ts.
|
||||
* Generates a named TypeScript type in payload-types.ts — `CmsLink` for the default
|
||||
* shape, a suffixed name for others (see `interfaceName`). All are assignable to `CmsLink`.
|
||||
*
|
||||
* fields: [buildLinkField()] // single link
|
||||
* fields: [buildLinkField({ disableLabel: true, appearances: false })] // clickable card
|
||||
@@ -46,10 +55,12 @@ export function buildLinkField({
|
||||
name = 'link',
|
||||
appearances = ['primary', 'secondary', 'link'],
|
||||
disableLabel = false,
|
||||
interfaceName,
|
||||
relationTo = 'pages',
|
||||
required = false,
|
||||
uploadTo = 'media',
|
||||
}: BuildLinkFieldOptions = {}): GroupField {
|
||||
const hasAppearance = Boolean(appearances && appearances.length)
|
||||
const pageAdmin = { condition: (_: unknown, s: SiblingWithType) => s?.type === 'internal' }
|
||||
const fields: Field[] = [
|
||||
{
|
||||
@@ -105,7 +116,7 @@ export function buildLinkField({
|
||||
fields.push({ name: 'label', type: 'text', localized: true, required })
|
||||
}
|
||||
|
||||
if (appearances && appearances.length) {
|
||||
if (appearances && hasAppearance) {
|
||||
const options = appearances.map((a) => (typeof a === 'string' ? { label: a, value: a } : a))
|
||||
fields.push({
|
||||
name: 'appearance',
|
||||
@@ -120,7 +131,7 @@ export function buildLinkField({
|
||||
type: 'group',
|
||||
admin: { hideGutter: true },
|
||||
fields,
|
||||
interfaceName: 'CmsLink',
|
||||
interfaceName: interfaceName ?? `CmsLink${hasAppearance ? '' : 'Plain'}${disableLabel ? 'NoLabel' : ''}`,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user