-
Notifications
You must be signed in to change notification settings - Fork 177
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
Added support for dynamic path params in client-only routes #119
base: master
Are you sure you want to change the base?
Conversation
This would be great to see! Any movement here? |
Hi @Hless, how did you implement your client only routes ? // gatsby-node.js
exports.createPage = async ({ actions }) => {
actions.createPage({
path: "/route/:param",
matchPath: "/route/:param",
component: path.resolve("./src/template/route.tsx")
})
} When I try to access |
Sorry for the late reply! Just came back from vacation. I have defined my routes as follows:
Big difference being that I omitted Edit: |
Got same issue and not quite understanding how to work it placed in gatsby-node.js
Then in my request.js file place
Still though not working at all as every time I pass something for :id it either shows 404 when I include en in the url and if I remove the en in the url it removes the :id |
Again, you should not use matchPath at all. Just define routes with named parameters in the Quick example:
Component:
|
Apart from it will return Because you cant use : |
Ah, that indeed looks like a bug for windows machines. Which is strange because Gatsby core supports this functionality: Which version of Gatsby do you use? It could be mitigated by replacing gatsby-plugin-intl/src/gatsby-node.js Line 79 in bf7fbbd
Feels kind of hacky though |
I am using Tried using your example and just nothing 404 error page |
Got it to work with but problem is I change from en to say fr and the actual language does not change and stays on en even though its fr in the url.
|
Anyone got any clue ? I was also able to get it to work but it was on en in url but showing in different language the last one in the array. |
That is because that is still not the intended use case for this PR... I had the same problem using your code, that is why I made this PR. You are also not using the latest gatsby, might want to try that first? But, the windows path problem made me realise that there is still work to do on this PR. @jojobagings78 I would also like to kindly request not to post further problems with code that is not related to the workings of this pull request. You could try to open a different ticket for that. |
Just cant seem to find a solution which shows how under developed this library is and everyone seems to be as lost as me. |
@jojobagings78 I've update this PR for my project and you could try it https://github.com/denplis/gatsby-plugin-intl/tree/matchpath Installation: Example of usage:
|
Thank you @Hless |
This is a proposed fix to support dynamic path parameters in routes.
Suppose you have a path called:
/user/:userId
. Version 0.3.x would not correctly pick up/user/14
for example, but would instead show a 404 page.With this PR I have implemented redirection (from /user/14 to /en/user/14 for example), while replacing the named path parameters.
This PR does not (yet) include support for wildcard path matching using
matchPath
, but seeks to forgo that in favour of named path params. Currently this is because the changes in the PR make use ofmatchPath
in order to match against paths without lang code prefix.See issue #68, #93, #101