Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How can I create a route alias in solidstart's file routing and keep layout?

$
0
0

I'm trying to wrap my head around how to best do nested layouting using SolidStart's file based routing. I have an old app with a "route alias" from "/" to "/some/nested/page/with/layouts". I'm trying to translate a SvelteKit middleware alias like this one:

import type { Reroute } from '@sveltejs/kit';const translated: Record<string, string> = {'/': '/some/nested/page/with/layouts'};export const reroute: Reroute = ({ url }) => {    if (url.pathname in translated) {        return translated[url.pathname];    }};

In particular, I need the layouting to be intact and I'm not sure how to do this. If I simply add another route to solid-router pointing out the leaf component:

<FileRoutes /><Route path="/" component={nested} />

the intermediate layout naturally is missing. Compare "/" and "/nested" here, the layout missing from the former:

https://stackblitz.com/edit/github-6armgx?file=src%2Fapp.tsx

Is there a middleware I should use instead? Or can I add another "path" to the FileRoute on the fly somehow?

I need this to be an alias, not a redirect.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>