diff --git a/src/plugins/fs_routes/mod.ts b/src/plugins/fs_routes/mod.ts index 9a7c9855..7ce463d9 100644 --- a/src/plugins/fs_routes/mod.ts +++ b/src/plugins/fs_routes/mod.ts @@ -221,12 +221,10 @@ export async function fsRoutes( // _app template if (skipApp && mod.path === "/_app") { - hasApp = false; continue; } else if (!skipApp && mod.config?.skipAppWrapper) { skipApp = true; if (hasApp) { - hasApp = false; // _app component is always first components.shift(); } diff --git a/src/plugins/fs_routes/mod_test.tsx b/src/plugins/fs_routes/mod_test.tsx index c1e957b4..13f0e272 100644 --- a/src/plugins/fs_routes/mod_test.tsx +++ b/src/plugins/fs_routes/mod_test.tsx @@ -558,6 +558,56 @@ Deno.test("fsRoutes - route overrides _app", async () => { expect(doc.body.firstChild?.textContent).toEqual("route"); }); +Deno.test("fsRoutes - route overrides _app does not affect other routes", async () => { + const server = await createServer({ + "routes/_500.tsx": { + config: { skipInheritedLayouts: true }, + default: () => <>error!, + }, + "routes/_app.tsx": { + default: (ctx) => ( +
+ app/ +
+ ), + }, + "routes/_layout.tsx": { + default: (ctx) => ( + <> + layout/ + + ), + }, + // By having "bar" come before "foo", this results in a bug + // where the app wrapper is missing from "foo". + "routes/bar.tsx": { + config: { + skipAppWrapper: true, + skipInheritedLayouts: true, + }, + default: () => <>bar, + }, + "routes/index.tsx": { default: () => <>index }, + "routes/foo.tsx": { default: () => <>foo }, + }); + + const [indexRes, fooRes, barRes] = await Promise.all([ + server.get("/"), + server.get("/foo"), + server.get("/bar"), + ]); + const [index, foo, bar] = await Promise.all([ + indexRes.text(), + fooRes.text(), + barRes.text(), + ]); + expect(parseHtml(index).body.firstChild?.textContent).toEqual( + "app/layout/index", + ); + expect(parseHtml(foo).body.firstChild?.textContent).toEqual("app/layout/foo"); + expect(parseHtml(bar).body.firstChild?.textContent).toEqual("bar"); +}); + Deno.test("fsRoutes - handler return data", async () => { const server = await createServer({ "routes/index.tsx": {