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:
co-authored by
Claude Opus 5.5
parent
d992d131a2
commit
3645e61f7d
@@ -46,6 +46,17 @@ fifteen ready page sections and ten page templates.
|
||||
`forms:<title>`, `pages:*`) — the run touches only the listed records; the rest are reported as
|
||||
`skip (not listed)`. The seed templates (`ipal-site`, `ipal-form`) read it.
|
||||
|
||||
### Fixed
|
||||
- **Sitemap, llms.txt, the site index (MCP `list_pages`):** the page assigned as the 404 page is no longer listed —
|
||||
it answers 404 at its own address (`unlistedPageIds(settings)`). A 404 page that is also the homepage stays.
|
||||
- **`buildImagesConfig` in production without R2:** with `R2_PUBLIC_URL` empty (the default: media served by the
|
||||
app) the site's own `/api/media/file/**` on `NEXT_PUBLIC_SERVER_URL` is allowed, so next/image no longer answers
|
||||
400. With R2 nothing changes; a production build on localhost still never opens private IPs.
|
||||
- **`fillGlobal`:** a choice field (select, radio, checkbox, number, date) still at its `defaultValue` counts as
|
||||
empty, so e.g. Theme → `defaultTheme: 'system'` can be seeded over the stored default `light`. Text is never
|
||||
overwritten, even when it equals a default.
|
||||
- **Docs:** `LanguageSwitcher` with `renderLabel` needs a `'use client'` wrapper (i18n.md, ipal-site).
|
||||
|
||||
### Changed
|
||||
- **Cookie banner / button colours** read the single token names (`--ipal-surface`, `--ipal-text` …) instead of
|
||||
`dark:` + `--ipal-*-dark`. With `tokens.css` they switch with the theme. Without it, the built-in fallback follows the
|
||||
|
||||
@@ -346,7 +346,7 @@ Full option lists of `createContentHelpers` / `createPageRoute` / `SiteProviders
|
||||
| `DEFAULT_MIDDLEWARE_MATCHER` | `@intecion/ipal-kit/next/middleware`, `@intecion/ipal-kit` | array `['/((?!api\|admin\|_next\|.*\\..*).*)']` (excludes `api`, `admin`, `_next`, files); paste into `config.matcher` as a literal — Next reads the matcher statically |
|
||||
| `AlternateLinksProvider` | `@intecion/ipal-kit/client` | layout provider that holds the current page's addresses per language (for `LanguageSwitcher`); `SiteProviders` does not mount it |
|
||||
| `AlternateLinksUpdater` | `@intecion/ipal-kit/client` | `<AlternateLinksUpdater links={{ pl, en }} />` on a page — reports its addresses in other languages |
|
||||
| `LanguageSwitcher` | `@intecion/ipal-kit/client` | headless language switcher (`config`, `currentLocale`, `classNames`, `renderLabel`) linking to the addresses from context |
|
||||
| `LanguageSwitcher` | `@intecion/ipal-kit/client` | headless language switcher (`config`, `currentLocale`, `classNames`, `renderLabel`) linking to the addresses from context. `renderLabel` is a function: pass it from a `'use client'` wrapper of your own, never from a server header (build fails) — i18n.md |
|
||||
| `useAlternateLinks()` | `@intecion/ipal-kit/client` | hook: `{ [locale]: url }` of the current page — for your own switcher |
|
||||
| `useSetAlternateLinks()` | `@intecion/ipal-kit/client` | setter hook used by `AlternateLinksUpdater` (usually not needed) |
|
||||
|
||||
@@ -512,6 +512,7 @@ The editor builds forms in the panel (Forms collection). The project does NOT wr
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
|---|---|---|
|
||||
| `unlistedPageIds(settings)` | `@intecion/ipal-kit` | Site settings → ids of pages with no URL of their own (the assigned 404 page, unless it is the homepage) — the sitemap, llms.txt and the site index skip them; use it in your own page lists |
|
||||
| `getSystemPagePath({ page, locale, config, homeSlug? })` | `@intecion/ipal-kit` | Page assigned in Site settings (read with `locale: 'all'`) → path in the language (`/pl` for the homepage, `/en/privacy-policy`) or `undefined` |
|
||||
| `ALL_SYSTEM_PAGE_ROLES` | `@intecion/ipal-kit` | Constant: all system page roles in a fixed order: `homepage`, `notFound`, `privacyPolicy`, `cookiePolicy`, `termsOfService` |
|
||||
| `LocaleView({ views, defaultLocale })` | `@intecion/ipal-kit/client` | Picks, from ready per-language views, the one from the URL (`/en/...`) — in `not-found.tsx` without `headers()` (the route stays static); used by `createNotFoundPage` |
|
||||
@@ -555,7 +556,7 @@ Server only (`pnpm payload run`); never import it from client code, the Payload
|
||||
| `createSeeder(payload, { dryRun?, update?, force?, only?, guard?, editCheck?, context?, pagesCollection?, formsCollection?, label?, log? })` | `@intecion/ipal-kit/seed` | The seed rules in one place → `{ upsertBySlug, upsertBy, fillGlobal, summary, dryRun, update, force, local, only }`. `only` (or `SEED_ONLY`) = the records the run may touch (`pages:kontakt`, `forms:<title>`, `global:<slug>`, `pages:*`), the rest → `skip (not listed)`; a run without it against production / a non-local database throws unless `IPAL_SEED_ALLOW_FULL=1` / `guard.allowFull: true` (after launch: named records only; dry runs are never refused; `guard: false` turns every guard off). Create-only by default, natural keys, never deletes, globals: empty fields only, every locale with `fallbackLocale: false` onto the same row ids, skips records edited since seeding, writes with `context` `{ ipalSeed, disableRevalidate, ipalSkipIndexNow }`. Throws when `update` runs on production / a non-local database without `IPAL_SEED_ALLOW_PROD_UPDATE=1`. Both seed templates use it. |
|
||||
| `upsertBySlug(collection, data \| data[], { slugField? })` | (method of `createSeeder`) | Matches by the default-locale slug; an array creates missing records first, so `{ $page: 'slug' }` links work in any order; `{ $form: 'title' }` = the form's id (`formsCollection`, default `forms`). |
|
||||
| `upsertBy(collection, key, data)` | (method) | Matches by other keys, e.g. a form by `{ title }`. |
|
||||
| `fillGlobal(slug, data)` | (method) | Fills only empty fields of a global (all seeded fields with `update` when untouched). |
|
||||
| `fillGlobal(slug, data)` | (method) | Fills only empty fields of a global — a choice (select, radio, checkbox, number, date) still at its `defaultValue` counts as empty, text never does (all seeded fields with `update` when untouched). |
|
||||
| `summary()` | (method) | Prints and returns `{ created, skipped, updated, skippedEdited, errors }`; exit 1 when `errors`. |
|
||||
| `isLocalDatabase(url, { localHosts? })` | `@intecion/ipal-kit/seed` | `true` for SQLite files, Unix sockets, localhost / 127.0.0.1 / ::1 (+ `SEED_LOCAL_HOSTS`). |
|
||||
| `writeLocales(payload, target, data, { context?, draft? })` | `@intecion/ipal-kit/seed` | Writes seed values (`{ pl, en }` per field) to `{ collection, id }` or `{ global }`: default locale first, then every other locale with `fallbackLocale: false` onto the same row ids. |
|
||||
|
||||
@@ -513,7 +513,7 @@ globals (the plugin's globals already refresh with `ipalKit({ revalidatePath })`
|
||||
`/en/…`; the footer has legal links in the page language.
|
||||
|
||||
**Turn off / override.** Navigation is entirely project code (the plugin provides fields and resolvers); `buildLinkField({
|
||||
relationTo, appearances: false, disableLabel })`, `LanguageSwitcher` (`classNames`, `renderLabel`) or your own on
|
||||
relationTo, appearances: false, disableLabel })`, `LanguageSwitcher` (`classNames`, `renderLabel` — only inside a `'use client'` wrapper of your own, i18n.md) or your own on
|
||||
`useAlternateLinks()`.
|
||||
|
||||
### Optional modules (outside the set; separate commit, entry in "Project decisions")
|
||||
|
||||
@@ -64,6 +64,10 @@ decision on that part; no hand-built replacement, no silent workaround. **Code r
|
||||
- Schema change with content in the database → **ipal-migrate-fields**, never "live".
|
||||
|
||||
## Phase 3 — Navigation and company data → **ipal-nav**
|
||||
Language switcher in the header: `LanguageSwitcher` (`/client`). With `renderLabel` (e.g. `PL` / `EN`) wrap it in
|
||||
your own `'use client'` file (`src/components/layout/LocaleSwitcher.tsx`) and render that from the server header —
|
||||
a function can't cross from a server to a client component, and `next build` fails. Example: i18n.md
|
||||
"Language switcher without 404".
|
||||
|
||||
## Phase 4 — Sections → **ipal-block** for every block
|
||||
Library blocks need no code: `libraryBlocks(blockOptions)` in the Pages layout and `createBlockRegistry(content,
|
||||
|
||||
+28
-1
@@ -352,6 +352,32 @@ LanguageSwitcher has NO styles (classNames) — not `variant="light|dark"`, so t
|
||||
fits any project design. A locale with no known alternate URL →
|
||||
falls back to the root `/{code}`.
|
||||
|
||||
**`renderLabel` needs a client wrapper.** `LanguageSwitcher` is a client component and `renderLabel` is a
|
||||
function; a server component (a header rendered on the server) cannot pass a function to a client
|
||||
component — `next build` fails ("Functions cannot be passed directly to Client Components"). Put the
|
||||
switcher with its `renderLabel` in a small client file of your own and render that from the server header:
|
||||
|
||||
```tsx
|
||||
// src/components/layout/LocaleSwitcher.tsx — a client component of your own
|
||||
'use client'
|
||||
import type { I18nConfig } from '@intecion/ipal-kit'
|
||||
import { LanguageSwitcher } from '@intecion/ipal-kit/client'
|
||||
|
||||
export function LocaleSwitcher({ config, locale }: { config: I18nConfig; locale: string }) {
|
||||
return (
|
||||
<LanguageSwitcher
|
||||
classNames={{ root: 'relative', trigger: '…', menu: '…', item: '…', itemActive: '…' }}
|
||||
config={config}
|
||||
currentLocale={locale}
|
||||
renderLabel={(l) => l.code.toUpperCase()}
|
||||
/>
|
||||
)
|
||||
}
|
||||
// header.tsx (server): <LocaleSwitcher config={i18nConfig} locale={locale} />
|
||||
```
|
||||
|
||||
Without `renderLabel` (the config labels) the server header can render `LanguageSwitcher` directly.
|
||||
|
||||
> **Where the page gets alternates:** the RSC page already resolves the route (resolveRoute);
|
||||
> from the same source compute the slugs per language (getLocalizedSlugs/buildLocalizedPath)
|
||||
> and pass them to AlternateLinksUpdater. This removes the custom AlternateLinksContext
|
||||
@@ -426,6 +452,7 @@ separate. The panel's language is what each user picks in *Account → Language*
|
||||
- `i18n` is required — the module cannot be turned off; one language = mode without the `/pl` prefix.
|
||||
- `config.localization` is currently always overridden from `i18n` (your own `localization` in payload.config does not survive); `fallback: false` turns off Payload's fallback.
|
||||
- Proxy: `createProxy` with options (`consentCategory`, `cookieName`, `exposeHeaders`, `markdown`, `policyVersion`) or your own proxy on `createLocaleMiddleware` + `negotiateLocale` / `matchAcceptLanguage`.
|
||||
- Switcher: `LanguageSwitcher` (`classNames`, `renderLabel`) or your own on `useAlternateLinks()`.
|
||||
- Switcher: `LanguageSwitcher` (`classNames`, `renderLabel` — only from a client component: wrap it, see
|
||||
"Language switcher without 404") or your own on `useAlternateLinks()`.
|
||||
- Paths: `buildLocalizedPath` / `switchLocalePath` with `homeSlug` and `prefix` — for your own link helpers.
|
||||
- Admin languages: your own `i18n.supportedLanguages` wins over the plugin's en + pl default; component texts via `i18n.translations.<lang>.ipal.<key>`.
|
||||
|
||||
@@ -50,6 +50,10 @@ locale — the caller decides the fallback (404, redirect). A slug equal to
|
||||
`homeSlug` (default `'home'`; a string or a per-language map) collapses to the root — for a home page
|
||||
with a different slug, pass `homeSlug`.
|
||||
|
||||
**Pages with no URL of their own:** `unlistedPageIds(settings)` (root) → the ids of pages assigned to a role that
|
||||
renders elsewhere — today the 404 page (unless it is also the homepage). The sitemap, llms.txt and the site index
|
||||
(MCP `list_pages`) leave them out; use it in your own lists of pages too.
|
||||
|
||||
## Typical case: `/{locale}` → home page
|
||||
|
||||
In the `[locale]/page.tsx` route you read `settings.homepage`, take its slug
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@ is an error for that record, never an empty relation. Ready pages made of librar
|
||||
|---|---|
|
||||
| `upsertBySlug(collection, data \| data[], { slugField })` | matches by the default-locale slug (`slugField`, default `slug`). With an array, missing records are created first (without fields that hold `$page` / `$form` links), then every record gets its full content, so pages can link to each other in any order |
|
||||
| `upsertBy(collection, key, data)` | matches by other natural keys, e.g. `{ title: 'Contact form' }` (all keys must match, default locale) |
|
||||
| `fillGlobal(slug, data)` | fills only the global's empty fields (the default locale decides). With `update` and an untouched global: every seeded field |
|
||||
| `fillGlobal(slug, data)` | fills only the global's empty fields (the default locale decides). A choice — select, radio, checkbox, number, date — still at the field's `defaultValue` counts as empty (Payload stores defaults on the first save, so `defaultTheme: 'system'` can be seeded over `light`); text is never treated so, even when it equals a default. With `update` and an untouched global: every seeded field |
|
||||
| `summary()` | prints the summary and returns `{ created, skipped, updated, skippedEdited, errors }` |
|
||||
|
||||
Each method prints one line per record (see [Running a seed](#running-a-seed)) and returns
|
||||
|
||||
+6
-4
@@ -259,10 +259,12 @@ variable; the component follows automatically.
|
||||
|
||||
- `buildImagesConfig({ serverUrl?, production?, publicUrl?, extraHosts? })` → `images` in
|
||||
`next.config.ts`: `formats` AVIF + WebP, `minimumCacheTTL` 31 days, `remotePatterns` from
|
||||
`R2_PUBLIC_URL` (`publicUrl`) and `extraHosts` (https). Outside production (`production`, default
|
||||
`NODE_ENV === 'production'`) also media served by the app — `/api/media/file/**` on
|
||||
`NEXT_PUBLIC_SERVER_URL` (`serverUrl`) — and `dangerouslyAllowLocalIP: true` for localhost /
|
||||
private networks (Next 16 rejects them otherwise). Spread the result and override:
|
||||
`R2_PUBLIC_URL` (`publicUrl`) and `extraHosts` (https). Media served by the app — `/api/media/file/**` on
|
||||
`NEXT_PUBLIC_SERVER_URL` (`serverUrl`) — are allowed outside production (`production`, default
|
||||
`NODE_ENV === 'production'`) **and in production when `R2_PUBLIC_URL` is empty** (the default without R2:
|
||||
Payload gives absolute URLs on the site's own host, which next/image would refuse with 400). Outside
|
||||
production also `dangerouslyAllowLocalIP: true` for localhost / private networks (Next 16 rejects them
|
||||
otherwise); a production build on localhost never gets it — set `production: false` for such a test run. Spread the result and override:
|
||||
`images: { ...buildImagesConfig(), /* your own */ }`.
|
||||
- `buildUploadSecurityHeaders({ collections? })` (default `['media']`) → headers for
|
||||
`/api/<slug>/file/:path*`: sandbox CSP + `nosniff` (uploaded SVG without scripts). security.md.
|
||||
|
||||
Reference in New Issue
Block a user