Admin follow-ups: localised stats tab title, scanner names, close label, favicon hint
- Statistics view: the browser-tab title follows the admin language.
Payload's custom-view meta.title is one plain string and its custom-view
metadata ignores i18n, so the view renders <DocumentTitle> (/admin) with the
translated title; it re-applies the title while the view is open because
Next streams the English metadata in after hydration. adminDocumentTitle()
adds admin.meta.titleSuffix the way Payload does.
- Cookie scanner: CookieIntegration.label may be { en, pl, ... }. The built-in
names without a product name come from the shared admin texts
(cookieIntegration*, cookieSourceProject); the scan endpoint answers in the
request's admin language and stored source names use the scanning editor's.
- Maintenance notice: getConstructionMode(locale) returns `locale`; the "x"
close button gets a screen-reader name "Close" / "Zamknij" (locale and
closeLabel props; constructionCloseLabel exported).
- Favicon: FaviconCheck (/admin, afterInput on Site settings -> Site icon)
warns in the admin language when the image is under 48x48 or not square,
without blocking the save; validateFaviconField shares faviconProblems().
- Docs, AGENT.md and skills: the above, plus Next.js 16.4.1 or later as the
minimum safe version (AGENT.md 4.11, ipal-setup, ipal-upgrade).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6f32ea4cdb
commit
546806fe39
@@ -1,14 +1,14 @@
|
||||
import type { FieldHook } from 'payload'
|
||||
|
||||
import { faviconProblems } from './faviconProblems.js'
|
||||
|
||||
/**
|
||||
* Field validation for the favicon upload: Google rejects favicons under 48×48,
|
||||
* so warn the editor at save time if the uploaded icon is too small or not
|
||||
* square. This ENFORCES the requirement instead of silently shipping a favicon
|
||||
* Google won't display.
|
||||
* Server-side check of the favicon upload: Google rejects favicons under 48×48,
|
||||
* and a non-square icon gets cropped. Logs a warning on save; it never blocks
|
||||
* the save. Editors see the same check under the field (`FaviconCheck`, /admin).
|
||||
*
|
||||
* Attach to the favicon field's validate (or as a beforeValidate hook on the
|
||||
* Media relationship). Non-blocking by default — returns a warning string that
|
||||
* Payload surfaces; make it throw if you want a hard block.
|
||||
* Attach as a beforeValidate hook on your own favicon field; the plugin wires it
|
||||
* on Site settings itself.
|
||||
*
|
||||
* Note: dimensions come from the related Media doc (Payload stores width/height
|
||||
* for image uploads), so this checks the resolved upload, not the raw file.
|
||||
@@ -23,26 +23,12 @@ export const validateFaviconField: FieldHook = async ({ req, value }) => {
|
||||
depth: 0,
|
||||
})
|
||||
|
||||
const width = (media as { width?: number }).width
|
||||
const height = (media as { height?: number }).height
|
||||
const mimeType = (media as { mimeType?: string }).mimeType
|
||||
|
||||
// SVG scales infinitely — skip size checks.
|
||||
if (mimeType === 'image/svg+xml') {return value}
|
||||
|
||||
if (typeof width === 'number' && typeof height === 'number') {
|
||||
if (width < 48 || height < 48) {
|
||||
req.payload.logger.warn(
|
||||
`[ipal] Favicon is ${width}×${height}px. Google requires ≥48×48 to ` +
|
||||
`display it in search results. Upload a larger square icon (96 or 192px).`,
|
||||
)
|
||||
}
|
||||
if (width !== height) {
|
||||
req.payload.logger.warn(
|
||||
`[ipal] Favicon is not square (${width}×${height}). Use a square icon ` +
|
||||
`so it isn't cropped in the browser tab or search results.`,
|
||||
)
|
||||
}
|
||||
for (const { height, key, width } of faviconProblems(media as { height?: number; mimeType?: string; width?: number })) {
|
||||
req.payload.logger.warn(
|
||||
key === 'faviconTooSmall'
|
||||
? `[ipal] Favicon is ${width}×${height}px. Google requires ≥48×48 to display it in search results. Upload a larger square icon (96 or 192px).`
|
||||
: `[ipal] Favicon is not square (${width}×${height}). Use a square icon so it isn't cropped in the browser tab or search results.`,
|
||||
)
|
||||
}
|
||||
} catch {
|
||||
// Media lookup failed — don't block the save over a validation warning.
|
||||
|
||||
Reference in New Issue
Block a user