question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Seems like the new way of using layouts doesn't work with index svelte files

See original GitHub issue

Describe the bug

Hi, It seems like if you create an index.svelte with a named layout doesn’t recognise it as the root ‘page’ of that folder or subfolder. eg:

├ x/
│ ├ __layout-foo.svelte
│ ├ index@foo.svelte
│ └ someotherpage@foo.svelte
├ __layout-global.svelte
└ index@global.svelte

here all index[@…].svelte files give 404’s (unless i’m not getting the concept of the new layouts)

Reproduction

create the following in your routes folder: src/routes/

├ x/
│ ├ __layout-foo.svelte
│ ├ index@foo.svelte
│ └ someotherpage@foo.svelte
├ __layout-global.svelte
└ index@global.svelte

start dev server and go to the root page

Logs

No response

System Info

System:
    OS: macOS 12.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 570.61 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.7.2 - /opt/homebrew/bin/node
    npm: 8.5.2 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 100.0.4896.75
    Firefox: 97.0.1
    Safari: 15.4
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.34 
    @sveltejs/adapter-node: ^1.0.0-next.73 => 1.0.0-next.73 
    @sveltejs/kit: next => 1.0.0-next.306 
    svelte: ^3.46.6 => 3.46.6

Severity

serious, but I can work around it

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
MiniKraken-Teamcommented, Apr 5, 2022

Same here … For example I have a folder under routes /login with /__layout-login.svelte and a route file index@login.svelte (renamed the existing __layout.reset.svelte to __layout-login and the index.svelte to index@login.svelte)

I get a 404 for /login not found when I use goto

The logic is simple - On the root layout , if the user has not logged in redirect to the login page Can’t figure out how to get this working now Is there a sample we can refer to?

Well i was doing some testing, on first sight it looks like it works with the other way of creating that ‘index’ page for a folder/subfolder. eg:

├ login/
│ └ register@login.svelte
├ __layout-login.svelte
├ login@login.svelte
├ __layout-global.svelte
└ index@global.svelte

This seems to work just fine, it is way less visible what an index page is for a certain path though (imo). This for me personally is only a workaround because in the case that you have a lot of ‘index’ pages for a lot of different paths with specifically other named layouts, it will get messy very quickly in the root of that folder. (just my opinion though)

1reaction
tsukhucommented, Apr 5, 2022

Ok this worked for the slug

/__layout-dash.svelte
/dash/[slug]@dash.svelte
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic behavior in Svelte: working with variables and props
Learn and put into practice some basic Svelte concepts, like creating components, passing data using props, rendering JavaScript expressions ...
Read more >
Using SvelteKit 1.0 on Vercel
The load function: SvelteKit has a unique way of loading page data using the load function. All +page.svelte files can have a sibling...
Read more >
Escape Root Layout Svelte Sveltekit - Stack Overflow
You can omit this, by using layout@.svelte . However in want to omit the root layout file at src/routes/layout.svelte . Is there a...
Read more >
Introduction • Docs • SvelteKit
In short, it's a UI framework that compiles your components to highly optimized vanilla JavaScript. Read the introduction to Svelte blog post and...
Read more >
Exploring SvelteKit in 2022 by Building a Portfolio Website
Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue do the bulk of their work...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found