Reputation: 350
I have a page with nested routes, for which I'd like to use the same template. The routes could look like this:
/foo
/foo/bar
This nesting is for ordering and internal reasons only. I want them to use the same template, i.e. I want it to be like this:
/src/routes/[foo]/+page.svelte # only this route needed
/src/routes/[foo]/[bar]/+page.svelte # use the upper template instead
Is this possible?
Upvotes: 1
Views: 1390
Reputation: 185280
This sound like a case for optional parameters, you would just define one route:
/src/routes/[foo]/[[bar]]/+page.svelte
bar
is optional so /foo
and /foo/bar
should lead to the same route.
Alternatively, if this does not cover the full real case, you can always extract the entire page content to a separate component and import that or define a +layout.svelte
at the upper level that contains everything the routes have in common.
Upvotes: 6
Reputation: 5
Yes, it is possible to use the same template for nested routes in a Svelte application
Upvotes: -3