vikejs / vike

🔨 Flexible, lean, community-driven, dependable, fast Vite-based frontend framework.
https://vike.dev
MIT License
4.4k stars 353 forks source link

When `Layout` is defined in `+config.ts` inside subfolders, it's reapplied. #1807

Closed traviscooper closed 3 months ago

traviscooper commented 3 months ago

Working on the following example: examples/full.

  1. A base Layout is defined in the root /pages folder.
  2. Inside /pages/starship there's another Layout component, which works perfectly as-is.
  3. Next, create a +config.ts inside /pages/starship that simply redefines what Layout component to use:
    
    // /pages/starship/+config.ts
    export { config }

import type { Config } from 'vike/types' import { Layout } from './+Layout'; import { Page } from './+Page';

// Default configs (can be overridden by pages) const config = { title: 'TESTING', Layout: Layout, // Reference to what's already being used, shouldn't affect anything Page: Page, } satisfies Config



4. `Layout` is applied twice. The only change was defining `Layout` here, and it should have no effect on the result.
![Screenshot](https://github.com/user-attachments/assets/27c9adfb-4413-4f6b-b0a7-bf321fc2a360)

Anything I'm missing?  Really appreciate all the hard work on this! 
traviscooper commented 3 months ago

If I rename the +Layout.tsx to Layout.tsx, it works properly and only applies it once.

Implies that the +Layout files are applied regardless of the +config.ts settings, instead of being replaced by the +config.ts layout setting.

brillout commented 3 months ago

Since +Layout is cumulative, I'd argue it works as intended.

But let me know if you believe it can cause a concrete issue.