Added not-found support for sitesettings
This commit is contained in:
@@ -160,5 +160,22 @@ export async function resolveRoute({
|
||||
const doc = found.docs[0]
|
||||
if (!doc) {return null}
|
||||
|
||||
// The page assigned as 404 in System Pages must not be reachable as a normal
|
||||
// 200 URL (/pl/strona-nie-znaleziona) — that's a soft-404 / duplicate. Treat
|
||||
// it as not found, so the route calls notFound() and not-found.tsx renders
|
||||
// that same page with a real 404 status. (If 404 = homepage, the homepage is
|
||||
// served from the root branch above and never reaches here by its own slug
|
||||
// in a way that matters — but guard anyway so we never hide the homepage.)
|
||||
const notFound = settings.notFound
|
||||
const homepage = settings.homepage
|
||||
const notFoundId =
|
||||
notFound && typeof notFound === 'object' ? (notFound as { id?: unknown }).id : notFound
|
||||
const homepageId =
|
||||
homepage && typeof homepage === 'object' ? (homepage as { id?: unknown }).id : homepage
|
||||
const docId = (doc as { id?: unknown }).id
|
||||
if (notFoundId != null && notFoundId === docId && notFoundId !== homepageId) {
|
||||
return null
|
||||
}
|
||||
|
||||
return { type: 'page', doc: doc as Record<string, unknown> }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user