Fixes from the reference site: 404 page unlisted, own-origin media, fillGlobal defaults, switcher docs

- sitemap, llms.txt and the site index leave out the page assigned as the 404
  page (unlistedPageIds, exported); it stays when it is also the homepage
- buildImagesConfig: in production with R2_PUBLIC_URL empty, allow the site's
  own /api/media/file/** so next/image no longer answers 400
- fillGlobal: a choice field (select, radio, checkbox, number, date) still at its
  defaultValue counts as empty; text is never overwritten
- docs: LanguageSwitcher renderLabel needs a 'use client' wrapper (i18n.md,
  ipal-site, ipal-setup, api.md)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 15:29:07 +01:00
co-authored by Claude Opus 5.5
parent d992d131a2
commit 3645e61f7d
19 changed files with 171 additions and 18 deletions
+6 -3
View File
@@ -7,8 +7,8 @@ import {
defaultHashField,
defaultUntouchedSeconds,
editedSinceSeed,
hasContent,
isLocalizedValue,
isUnsetValue,
localesOf,
localize,
projectOnto,
@@ -426,9 +426,12 @@ export function createSeeder(payload: BasePayload, options: SeederOptions = {}):
if (!listed(`global:${slug}`)) {return report(notListed(label))}
try {
const target = { global: slug }
const withHash = hasHashField(payload.config.globals.find((g) => g.slug === slug)?.fields as undefined | unknown[])
const global = payload.config.globals.find((g) => g.slug === slug)
const withHash = hasHashField(global?.fields as undefined | unknown[])
const fieldOf = (name: string) => (global?.flattenedFields as { defaultValue?: unknown; name?: string; type?: string }[] | undefined)?.find((f) => f.name === name)
const cur = await readSeedTarget(payload, target, defaultLocale)
const empty = Object.keys(data).filter((k) => !hasContent(cur[k]))
// Empty, or a choice still at its default value (e.g. Theme → light): never text an editor wrote.
const empty = Object.keys(data).filter((k) => isUnsetValue(cur[k], fieldOf(k)))
let keys = empty
let edited: null | string = null
if (update) {
+14
View File
@@ -175,6 +175,20 @@ export async function writeLocales(
}
/** True when a value has content (non-empty text, a number, true, or a nested one). */
/** Field types whose stored value is a choice, not text an editor wrote. */
const CHOICE_TYPES = new Set(['checkbox', 'date', 'number', 'point', 'radio', 'select'])
/**
* A global field nobody has set yet: empty, or — for a choice (select, radio, checkbox, number, date) —
* still holding the field's own `defaultValue`, which Payload stores on the first save of the global.
* Text an editor wrote is never "unset", even when it equals a default.
*/
export function isUnsetValue(value: unknown, field?: { defaultValue?: unknown; type?: string }): boolean {
if (!hasContent(value)) {return true}
if (!field || !CHOICE_TYPES.has(field.type ?? '') || field.defaultValue === undefined || typeof field.defaultValue === 'function') {return false}
return JSON.stringify(value) === JSON.stringify(field.defaultValue)
}
export function hasContent(v: unknown): boolean {
if (typeof v === 'string') {return v.trim() !== ''}
if (typeof v === 'number' || v === true) {return true}