Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Layouts don't work when using endpoints to populate data for template #5595

Closed
hartwm opened this issue Jul 18, 2022 · 3 comments
Closed
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.
Milestone

Comments

@hartwm
Copy link

hartwm commented Jul 18, 2022

Describe the bug

You can't use custom layouts if you use a named endpoint to separate data logic from template logic.

Reproduction

Create a structure such as
src/routes/hello.ts
src/routes/[email protected]
src/routes/__layout-foo.svelte

GET request to /helloand it returns body data from hello.ts not html from [email protected]

Logs

No console errors occur

System Info

System:
    OS: macOS 12.2.1
    CPU: (10) x64 Apple M1 Pro
    Memory: 22.69 MB / 32.00 GB
    Shell: 5.1.4 - /usr/local/bin/bash
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  Browsers:
    Brave Browser: 103.1.40.105
    Chrome: 103.0.5060.114
    Edge: 103.0.1264.62
    Firefox: 102.0.1
    Safari: 15.3
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.55 
    @sveltejs/adapter-vercel: ^1.0.0-next.48 => 1.0.0-next.60 
    @sveltejs/kit: next => 1.0.0-next.368 
    svelte: ^3.46.0 => 3.47.0 
    vite: ^2.9.13 => 2.9.14

Severity

serious, but I can work around it

Additional Information

I can work around it by combining data requests and template markup into a single svelte file

@Rich-Harris
Copy link
Member

You can't have separate hello.ts and [email protected] routes — the endpoint should be renamed to [email protected]. (The duplication is unfortunate, and would be solved by #5037, but there's some consensus-building to do before we get there.)

We should probably throw an error when you have conflicting routes like these.

@Rich-Harris Rich-Harris added this to the 1.0 milestone Jul 18, 2022
@Rich-Harris Rich-Harris added the bug Something isn't working label Jul 18, 2022
@hartwm
Copy link
Author

hartwm commented Jul 18, 2022

ahhh didn't think to try that, oversight on my end, but not intuitive thought pattern I guess considering one is for layout and one is just for passing data.
for the record if i could prerender and keep data static i would prefer to have my routes more like api/posts.ts, even if it means having to do a quick reference to it within the template file. i believe there is an open issue around this, but it would prevent me from this sort of thing anyway

@benmccann benmccann added the p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. label Jul 19, 2022
@madeleineostoja
Copy link

Fixed by #5778

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.
Projects
None yet
Development

No branches or pull requests

4 participants