Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallback route if all routes including nested ones failed to match #264

Open
jsprog opened this issue Nov 5, 2023 · 4 comments
Open

fallback route if all routes including nested ones failed to match #264

jsprog opened this issue Nov 5, 2023 · 4 comments

Comments

@jsprog
Copy link

jsprog commented Nov 5, 2023

This should've went into the Discussions tab if it was available.

I'm trying to achieve the following:

  • app with multiple layouts (Layout Route + Layout Router per layout).
  • Layout Route should fail to match if all the nested routes failed to match.

unfortunately, no way to reach Not Found.

<script>
    import {Router, Route} from 'svelte-routing'
</script>

<Router>
    <Route path="/*">
        <div>Main Layout</div>
        <Router>
            <Route path="/">Main</Route>
            <Route path="/nested">nested within main layout</Route>
        </Router>
    </Route>

    <Route path="/config/*">
        <div>Config Layout</div>
        <Router>
            <Route path="/">Config Listing</Route>
            <Route path="/1">Config 1</Route>
            <Route path="/2">Config 2</Route>
        </Router>
    </Route>

    <Route path="*">Not Found</Route>
</Router>
@krishnaTORQUE
Copy link
Collaborator

<script>
    import {Router, Route} from 'svelte-routing'
</script>

<Router>
    <Route path="/">
        <div>Main Layout</div>
        <Router>
            <Route path="/">Main</Route>
            <Route path="/nested">nested within main layout</Route>
            <Route path="*">Not Found in Root</Route>
        </Router>
    </Route>

    <Route path="/config">
        <div>Config Layout</div>
        <Router>
            <Route path="/">Config Listing</Route>
            <Route path="/1">Config 1</Route>
            <Route path="/2">Config 2</Route>
            <Route path="*">Not Found in Config</Route>
        </Router>
    </Route>

    <Route path="*">Not Found</Route>
</Router>

Try this
Not tested

@jsprog
Copy link
Author

jsprog commented Nov 7, 2023

Thank you, but the example you're suggesting is against the requirements as specified in my post (subject and content)

Requirements:

  1. Top level fallback route (not found): the example you're providing won't solve this and instead your suggesting additional not found routes for every layout, and thus leaving some content provided by the layout rendered on screen!
  2. navigation within sub routes: removing the trailing * or /* in your example is killing it!

@krishnaTORQUE
Copy link
Collaborator

Suggestion giving reason is to understand the issue deeply.
If this works then I can understand the problem better & identify the pin point of where to fix it.

@jsprog
Copy link
Author

jsprog commented Nov 7, 2023

@krishnaTORQUE, I really appreciate your efforts, but at least have some respect for my efforts with the issue I'm reporting.

The example you're providing is deviating from the subject and wrong at all, and no way you'll reach /nested, /config/1 and /config/2 because they're behind absolute routes (/ and /config). Also forget about the useless nested not found routes and instead how we'll fallback everything to a single not found route?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants