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:
Radosław Smoliński
2026-10-19 21:32:40 +02:00
co-authored by Claude Opus 5.5
parent 23e033d7d7
commit faa4ad679c
55 changed files with 1298 additions and 58 deletions
+19 -1
View File
@@ -24,11 +24,19 @@ describe('mediaImageProps', () => {
})
test('placeholder and focal point', () => {
const p = mediaImageProps({ ...image, focalX: 30, focalY: 70, placeholder: { blurDataURL: 'data:x', color: '#123456' } })
const p = mediaImageProps({ ...image, focalX: 30, focalY: 70, mimeType: 'image/jpeg', placeholder: { blurDataURL: 'data:x', color: '#123456' } })
expect(p).toMatchObject({ blurDataURL: 'data:x', placeholder: 'blur', style: { backgroundColor: '#123456', objectPosition: '30% 70%' } })
expect(mediaImageProps({ ...image, focalX: 50, focalY: 50 })?.style).toBeUndefined()
})
test('placeholder colour only where no alpha can show it (JPEG), unless forced', () => {
const png = { ...image, mimeType: 'image/png', placeholder: { blurDataURL: 'data:x', color: '#000000' } }
expect(mediaImageProps(png)?.style).toBeUndefined()
expect(mediaImageProps(png)?.placeholder).toBe('blur')
expect(mediaImageProps(png, { placeholderColor: true })?.style).toEqual({ backgroundColor: '#000000' })
expect(mediaImageProps({ ...png, mimeType: 'image/jpeg' }, { placeholderColor: false })?.style).toBeUndefined()
})
test('video, PDF and bare ids give null; decorative alt override', () => {
expect(mediaImageProps({ ...image, mimeType: 'video/mp4' })).toBeNull()
expect(mediaImageProps({ mimeType: 'application/pdf', url: '/x.pdf' })).toBeNull()
@@ -88,4 +96,14 @@ describe('buildMediaPlaceholderHook', () => {
await buildMediaPlaceholderHook()({ args: { data: svgData }, operation: 'create', req: { ...req, file: { data: png, mimetype: 'image/svg+xml' } } } as never)
expect(svgData.placeholder).toBeUndefined()
})
test('transparent image: blur kept, no colour', async () => {
const logo = await sharp({ create: { background: { alpha: 0, b: 255, g: 255, r: 255 }, channels: 4, height: 100, width: 300 } }).png().toBuffer()
const data: Record<string, unknown> = {}
const req = { file: { data: logo, mimetype: 'image/png' }, payload: { config: { sharp }, logger: { warn: vi.fn() } } }
await buildMediaPlaceholderHook()({ args: { data }, operation: 'create', req } as never)
const ph = data.placeholder as { blurDataURL: string; color: null | string }
expect(ph.blurDataURL).toMatch(/^data:image\/webp;base64,/)
expect(ph.color).toBeNull()
})
})