fix: rename layout config options (#1619)

This commit is contained in:
Marvin Hagemeister
2023-08-14 15:47:36 +02:00
committed by GitHub
parent ba67d895ce
commit 6436a43dce
13 changed files with 124 additions and 63 deletions
+7 -7
View File
@@ -15,7 +15,7 @@ import {
AsyncRoute,
ErrorPage,
Island,
LayoutModule,
LayoutRoute,
Plugin,
PluginRenderFunctionResult,
PluginRenderResult,
@@ -83,7 +83,7 @@ export interface RenderOptions<Data> {
islands: Island[];
plugins: Plugin[];
app: AppModule;
layouts: LayoutModule[];
layouts: LayoutRoute[];
imports: string[];
dependenciesFn: (path: string) => string[];
url: URL;
@@ -182,11 +182,11 @@ export async function render<Data>(
// Only inherit layouts up to the nearest root layout.
// Note that the route itself can act as the root layout.
let layouts = opts.layouts;
if (!opts.route.rootLayout) {
if (opts.route.inheritLayouts) {
let rootIdx = 0;
let layoutIdx = opts.layouts.length;
while (layoutIdx--) {
if (opts.layouts[layoutIdx].config?.rootLayout) {
if (!opts.layouts[layoutIdx].inheritLayouts) {
rootIdx = layoutIdx;
break;
}
@@ -265,13 +265,13 @@ export async function render<Data>(
const renderStack: any[] = [];
// Check if appLayout is enabled
if (
opts.route.appLayout &&
layouts.every((layout) => layout.config?.appTemplate !== false)
opts.route.appTemplate &&
layouts.every((layout) => layout.appTemplate)
) {
renderStack.push(opts.app.default);
}
for (let i = 0; i < layouts.length; i++) {
renderStack.push(layouts[i].default);
renderStack.push(layouts[i].component);
}
renderStack.push(component);