Skip to content
Discussion options

You must be logged in to vote

I think I've found a working solution, not sure if it's the best solution, but it seems to work.

I've created a __layout.svelte in the /todos/[id] folder. In there, in the load function, I call a standalone endpoint (created as /api/todos/[id].json.ts which will take care of fetching the todo by ID. In the __layout.svelte component, I render a Todo component where the todo is passed as a prop. THe last element in the __layout.svelte is a <slot> which will take care of rendering the Edit component.

My routes folder now looks as follows (maybe handy for anyone that has the same usecase)

- /api
    - /todos
        - [id].json.ts
- /todos
    - /[id]
        - /edit
            - index.svelt…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gerardkd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant