dashboard or /item), and others that are 'marketing' routes that should have a different layout ( /blog or /testimonials). Perhaps you have some routes that are 'app' routes that should have one layout (e.g. In some cases, that might not be what you want. Advanced layoutsīy default, the layout hierarchy mirrors the route hierarchy. character, you may find it useful to encode these characters when creating e.g.well-known routes: src/routes/well-known/. Since TypeScript struggles with directories with a leading. (Unlike JavaScript string escaping, there's no need to use surrogate pairs to represent code points above ffff.) To learn more about Unicode encodings, consult Programming with Unicode. The format for a Unicode escape sequence is where nnnn is a valid value between 0000 and 10ffff. In other words, these are equivalent: src/routes// page.svelte Generally you won't need to as you can use the unencoded character directly, but if - for some reason - you can't have a filename with an emoji in it, for example, then you can use the escaped characters. You can also use Unicode escape sequences. You can determine the hexadecimal code for a character with JavaScript: To use these characters in your routes, you can use hexadecimal escape sequences, which have the format where nn is a hexadecimal character code:įor example, to create a /smileys/:-) route, you would create a src/routes/smileys/-/ page.svelte file. The # and % characters have special meaning in URLs, and the ( ) characters have special meaning to SvelteKit, so these also can't be used directly as part of your route. Some characters can't be used on the filesystem - / on Linux and Mac, \ / : * ? " | on Windows. resulting in this ordering, meaning that /foo-abc will invoke src/routes/foo-abc/ page.svelte, and /foo-def will invoke src/routes/foo-/ page.svelte rather than less specific routes: src/routes/foo-abc/ page.svelte In other words x/]/z is treated equivalently to x/z for the purposes of sorting ] and parameters are ignored unless they are the final part of the route, in which case they are treated with lowest priority.Parameters with matchers ( ) are higher priority than those without ( ).a route with no parameters is more specific than a route with one dynamic parameter, and so on) More specific routes are higher priority (e.g.To do so, it sorts them according to the following rules. SvelteKit needs to know which route is being requested. For example each of these routes would match /foo-abc: src/routes/ / page.svelte It's possible for multiple routes to match a given path. Matchers run both on the server and in the browser. ts files which may be used to unit test your matchers. If the pathname doesn't match, SvelteKit will try to match other routes (using the sort order specified below), before eventually returning a 404.Įach module in the params directory corresponds to a matcher, with the exception of *.test. and augmenting your routes: src/routes/archive/
0 Comments
Leave a Reply. |