feat: allow layout and _app overrides (#1611)

This commit is contained in:
Marvin Hagemeister
2023-08-09 16:35:53 +00:00
committed by GitHub
parent 81ae7b8427
commit 7ebaf0404d
13 changed files with 277 additions and 20 deletions
+10
View File
@@ -253,6 +253,8 @@ export class ServerContext {
component,
handler,
csp: Boolean(config?.csp ?? false),
appLayout: Boolean(config?.appTemplate ?? true),
rootLayout: Boolean(config?.rootLayout ?? false),
};
routes.push(route);
} else if (isMiddleware) {
@@ -288,6 +290,8 @@ export class ServerContext {
component,
handler: handler ?? ((req) => router.defaultOtherHandler(req)),
csp: Boolean(config?.csp ?? false),
appLayout: Boolean(config?.appTemplate ?? true),
rootLayout: Boolean(config?.rootLayout ?? false),
};
} else if (
path === "/_500.tsx" || path === "/_500.ts" ||
@@ -308,6 +312,8 @@ export class ServerContext {
handler: handler ??
((req, ctx) => router.defaultErrorHandler(req, ctx, ctx.error)),
csp: Boolean(config?.csp ?? false),
appLayout: Boolean(config?.appTemplate ?? true),
rootLayout: Boolean(config?.rootLayout ?? false),
};
}
}
@@ -971,6 +977,8 @@ const DEFAULT_NOT_FOUND: UnknownPage = {
name: "_404",
handler: (req) => router.defaultOtherHandler(req),
csp: false,
appLayout: true,
rootLayout: false,
};
const DEFAULT_ERROR: ErrorPage = {
@@ -981,6 +989,8 @@ const DEFAULT_ERROR: ErrorPage = {
component: DefaultErrorHandler,
handler: (_req, ctx) => ctx.render(),
csp: false,
appLayout: true,
rootLayout: false,
};
export function selectSharedRoutes<T>(