Lazy 404: createNotFoundPage({ load }) + renderNotFoundView, NotFoundLoader
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]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8b35986635
commit
166bf51e53
@@ -8,6 +8,26 @@ wersji naraz przejdź po kolei wszystkie sekcje „Wymaga zmian w projekcie” o
|
||||
wersji, którą masz. Nowe wydanie = nowa sekcja na górze; najstarsze usuwamy
|
||||
dopiero powyżej 20.
|
||||
|
||||
## 1.12.0
|
||||
|
||||
### Nowe
|
||||
- **Leniwa strona 404** — `createNotFoundPage(content, { load })` + `renderNotFoundView(content, { blocks, blockProps,
|
||||
fallback }, locale)` (`/rsc`) w server action projektu; `<NotFoundLoader>` (`/client`). Next wkłada drzewo
|
||||
`not-found` layoutu do danych RSC KAŻDEJ strony; wariant `{ blocks }` renderował tam stronę 404 z panelu w każdym
|
||||
języku (404 = strona główna, 2 języki: HTML strony głównej 195 → 146 KB gzip, dane RSC −42%). Teraz w danych jest
|
||||
tylko loader, treść przychodzi przy wyświetleniu 404. `renderNotFoundView` przyjmuje tylko skonfigurowane języki.
|
||||
Opis: pages.md → „Strona 404”.
|
||||
|
||||
### Wymaga zmian w projekcie
|
||||
Nic obowiązkowego — `createNotFoundPage(content, { blocks })` działa jak dotąd. Zalecane (każdy projekt z 404
|
||||
z panelu, zwłaszcza 404 = strona główna albo kilka języków):
|
||||
1. `src/app/(frontend)/[locale]/notFoundView.ts` (`.tsx`, gdy `fallback` to JSX):
|
||||
`'use server'` + `export async function loadNotFoundView(locale: string) { return renderNotFoundView(content,
|
||||
{ blocks: blockRegistry, blockProps, fallback }, locale) }` — opcje przenieś z `not-found.tsx`.
|
||||
2. `not-found.tsx`: `export default createNotFoundPage(content, { load: loadNotFoundView })`.
|
||||
3. Sprawdzenie: w HTML dowolnej strony brak treści strony 404 (`self.__next_f`), a nieznany adres
|
||||
(np. `/xx/test`) nadal daje 404 z treścią z panelu.
|
||||
|
||||
## 1.11.1
|
||||
|
||||
### Nowe
|
||||
|
||||
Reference in New Issue
Block a user