Repository navigation
Commit e38b2bf
authored
fix(docs): keep the 404 title after hydration via a metadata export (#219)
The served 404 carried two title elements: the component's own, then Next's metadata title from the root layout's title.default. The browser took the first while parsing; on hydration React re-inserted the metadata title ahead of it and the tab read plain ObjectOS -- a bookmark or history entry for a dead link was indistinguishable from the site index.
next-app-loader installs not-found.tsx as the page module of /_not-found rather than as an error boundary, so collectMetadata reads a metadata export here through the ordinary getLayoutOrPageModule path. Confirmed from node_modules and by a sentinel probe read out of the prerendered document.
title.absolute rather than a plain string: the root layout declares title.template, which would otherwise run the 404 title through it and reintroduce the drift in a new spelling. The export derives from the same constant that feeds the title element so the two cannot diverge.
This also repairs #213's title line, which the same mechanism had been reverting since it landed -- /zh-Hans/no-such-page showed the localized title at parse time and ObjectOS after. #213's lang attribute and body copy were unaffected and are untouched here.
After hydration the title is English in every locale: this boundary sits above the [lang] segment, and reading the locale dynamically costs 577 prerendered documents. Not taken.
/_not-found still Static, 577 prerendered files, 996/996. One stripped-body hash across thirteen unmatched URLs, +26 bytes versus main -- exactly the title difference. Healthy controls byte-identical.
Closes #2121 parent e8b2062 commit e38b2bf
1 file changed
Lines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
90 | 124 | | |
91 | 125 | | |
92 | 126 | | |
| |||
112 | 146 | | |
113 | 147 | | |
114 | 148 | | |
115 | | - | |
| 149 | + | |
116 | 150 | | |
117 | 151 | | |
118 | 152 | | |
| |||
0 commit comments