1.18.0 performance items: reference 404 placeholder and heading font without preload, lazy form and Turnstile code (eager entry /client/eager), Turnstile space kept, background video paused for reduced motion, card hover on opacity, metadata stripped on upload, MongoDB TTL indexes for the consent log and statistics, unused-media notice, version limit for the plugin's entities

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 15:38:38 +01:00
co-authored by Claude Opus 5.5
parent 076b3ef707
commit d628839235
47 changed files with 2546 additions and 78 deletions
+19
View File
@@ -0,0 +1,19 @@
/**
* The plugin's own collections and globals turn versions on nowhere. When a project turns them on (globalOverrides,
* collectionOverrides, formOverrides…) without a limit, each keeps at most 20 versions per document (1.18.0;
* docs/performance.md §6) instead of Payload's 100 — a global like Site integrations is saved by the site itself on
* every status change. A limit the project writes wins (`max` for globals, `maxPerDoc` for collections, 0 =
* unlimited). Payload trims the oldest versions of a document on its next save.
*/
export const PLUGIN_VERSION_LIMIT = 20
type Versioned = { slug: string; versions?: unknown }
export function withVersionLimit<T extends Versioned>(entity: T, kind: 'collection' | 'global', limit = PLUGIN_VERSION_LIMIT): T {
const v = entity.versions
if (!v) {return entity}
const key = kind === 'global' ? 'max' : 'maxPerDoc'
if (v === true) {return { ...entity, versions: { [key]: limit } }}
if (typeof v === 'object' && typeof (v as Record<string, unknown>)[key] !== 'number') {return { ...entity, versions: { ...(v as object), [key]: limit } }}
return entity
}