Asked By: Anonymous
Let’s say I have a
/foo route. But sometimes people hit
/foo with a language parameter:
/fr/foo. And other times they might hit it with a language and a country:
So I need a routing table like
[country]/[language]/foo [language]/foo /foo
That all direct to the same page.
Should I create a tree like this?
src/routes â””â”€â”€ [country] â””â”€â”€ [language] â””â”€â”€ foo.svelte
If that’s the answer then how do I direct
Answered By: Anonymous
Optional parameters aren’t yet supported, but you can almost fake it with ‘rest routes’ (which I’ve just realised aren’t yet documented ðŸ¤¦â€â™‚ï¸) â€”
routes/[...parts]/foo.svelte would render
foo.svelte with a
page.params.parts array that contained the preceding segments.
Unfortunately that doesn’t match
/foo, which it arguably should. I’ve raised an issue: https://github.com/sveltejs/sapper/issues/765