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

Route hierarchy #59

Open
YerkoPalma opened this issue Oct 24, 2016 · 1 comment
Open

Route hierarchy #59

YerkoPalma opened this issue Oct 24, 2016 · 1 comment

Comments

@YerkoPalma
Copy link

I'm building a toy app with sheet-router and yo-yo, I have this route defined.

const router = sheetRouter({ default: '/404' }, [
  [ '/posts', postsComponent,
    ['/new', newPostComponent],
    ['/:post', postComponent,
      ['/comments', commentsComponent]
    ]
  ],
  ['/404', (params) => html`<div>Oh no, path not found! ${JSON.stringify(params, null, 2)}</div>`],
])

With that I want the following behaviour

  • /posts/new: Render newPostComponent
  • /posts/132: Render postComponent with params.post = 132

What I'm actually getting is

  • /posts/new: Render newPostComponent
  • /posts/132: Render the default route with no params

I though that if some route is not found, it would evaluate if some other route would match, and only if no one matched the given path show the default route.

So, is my code right for what I'm trying to achieve? Or am I misunderstanding how the router resolve paths?

Thanks in advance.

@yoshuawuyts
Copy link
Owner

Hmmmmmm, yeah this might have been the case at some point, but the way wayfarer's internals are right now are quite complex as-is to be honest. I'd be open for a PR that adds this behavior in wayfarer, on the sole condition that we test it well - I think supporting this is definitely reasonable

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