Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Static build can't handle named path parameter #1223

Open
thangngoc89 opened this issue Dec 26, 2017 · 4 comments
Open

Static build can't handle named path parameter #1223

thangngoc89 opened this issue Dec 26, 2017 · 4 comments

Comments

@thangngoc89
Copy link
Contributor

I have a named parameter in a route like this one

<Route
      path="/keywords/:keyword"
      component={createContainer(
        KeywordDetailsRoute.jsComponent,
        KeywordDetailsRoute.queries
      )}
    />

It works flawlessly on dev mode build static build can't resolve it.
This is what the folder structure looks like:

image

If this is something that can't be analyzed during static build then we should warns user in dev mode.

@thangngoc89
Copy link
Contributor Author

hmm. After I edited it to use * it still can't generate keywords page

@thangngoc89
Copy link
Contributor Author

thangngoc89 commented Dec 26, 2017

Actually, this is a limitation / bug ? (cc @MoOx)
After debugging this, here's what I do to have prerender routes for relations:

Assuming we have a package like this:

{
  keywords: ["a", "b", "c"]
}

Case 1: using named parameter

On the route definition, we must use keywords as route parameter like this:

<Route
  path="/keywords/:keywords"
  component={KeywordDetailRoute}
/>

Case 2: Using a star (*)

I'm 99% sure that this is a bug. On this line

https://github.com/phenomic/phenomic/blob/33258f441b44302841ebe055319741d3ed985581/packages/core/src/prerender/resolve.js#L137

the condition check key === mainKey only pass when rendering a direct mapping (in this case a package), it's not working for relations(tags, keywords, ...) which is use as the key in comparison.

I tried to remove the condition check and it works for my use cases, not sure if there is any consequences.

thangngoc89 added a commit to thangngoc89/redex-phenomic that referenced this issue Dec 26, 2017
thangngoc89 added a commit to thangngoc89/redex-phenomic that referenced this issue Dec 26, 2017
@MoOx
Copy link
Owner

MoOx commented Dec 27, 2017

Indeed, we do not do any magic to resolve a word to its plural version like it was in 0.x (tags => tag, category => categories - we were trying "y => ies" and "+s").

Indeed for meta we need the name (I think). Not sure what is the best to improve the situation.
The * can make sense for ids, but for a named parameter... How do we know the name?

@thangngoc89
Copy link
Contributor Author

I have an idea for this. Workinf on a PoC

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

No branches or pull requests

2 participants