Next puts a layout's not-found tree into the RSC payload of every page under it. The eager
createNotFoundPage({ blocks }) rendered the panel's 404 page there in every locale, so with
404 = homepage each page shipped the homepage twice (homepage HTML 195 -> 146 KB gzip).
With { load } only <NotFoundLoader> is in the payload; the content comes from the project's
server action (renderNotFoundView, locale checked against configured locales) when a 404 shows.
The eager variant is unchanged. Docs: pages.md, i18n.md, AGENT.md, PROGRAMISTA, ipal-setup, CHANGELOG.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
9 lines
407 B
TypeScript
9 lines
407 B
TypeScript
/**
|
|
* The locale from the first URL segment (`/en/...` → `en`), or `defaultLocale`
|
|
* when the segment isn't one of `locales` (single-locale site, unknown prefix).
|
|
*/
|
|
export function localeFromPath(pathname: string, locales: readonly string[], defaultLocale: string): string {
|
|
const segment = pathname.split('/').filter(Boolean)[0] ?? ''
|
|
return locales.includes(segment) ? segment : defaultLocale
|
|
}
|