routify.dev icon indicating copy to clipboard operation
routify.dev copied to clipboard

Documentation: $params helper examples

Open gianmarco27 opened this issue 1 year ago • 11 comments

Current examples provided in the documentation are a bit misleading as they rapresent a usage of the $params helper function that does not follow the default implementation, it is specified below that by default the native URLSearchParams function is used, i believe it would be helpful and clearer, either to adapt the examples to the actual default usage, or add the custom function used to obtain such result, and highlight better that the default behaviour would be different from the one displayed in the example.

P.S. Awesome tool! keep it up :)

gianmarco27 avatar Jul 11 '22 13:07 gianmarco27

Thanks for spotting this. It seems there's something missing in the description.

jakobrosenberg avatar Jul 14 '22 06:07 jakobrosenberg

IIRC the behavior is the same as described here. https://v3.ci.routify.dev/docs#guide/introduction/parameters

jakobrosenberg avatar Jul 14 '22 06:07 jakobrosenberg

Yes, in the V3 documentation this is made way clearer! :)

gianmarco27 avatar Jul 14 '22 09:07 gianmarco27

Thing to be noted tho, during my tests i tryed a usage like "/subfolder/page/:id", while having a fallback page configured at root level in my folder structure, and instead of hitting the "/subfolder/page" with param { page: id }, it was going straight to the root level fallback.

It only worked as intended when i configured it to use only URLSearchParams

gianmarco27 avatar Jul 15 '22 14:07 gianmarco27

That sounds like a bug. Can you create a minimal reproducible?

jakobrosenberg avatar Jul 15 '22 15:07 jakobrosenberg

So i tryed to go back and reproduce the behaviour i stated above, but it turns out i was missing the Syntactical sugar section of the V3 documentation, where i should name my destination file wrapped in [ ] to have it work as a path parameter. No bug in here, just a problem between the chair and the screen. Thank you for your patience, i hope my feedback can help you make V2 documentation clearer for future use.

gianmarco27 avatar Jul 25 '22 14:07 gianmarco27

I'm not sure this is the right channel, but since i'm in the topic and it could potentially be a new issue, i'm going to introduce it here. Should it be possible to use path parameters like "/subfolder/page/:id" together with named routes in a $goto helper? $goto('tools.show', {tool: id}) with file named [tool].svelte

From what i'm testing now, it correctly writes the intended path in the browser history, but routify appears to be routing me back to the "/subfolder/index", by visiting the same url via the $url helper inside a link, or with the "back" browser button i reach correctly the intended page

gianmarco27 avatar Jul 26 '22 16:07 gianmarco27

@gianmarco27 I'm not sure I follow. Could you give me a step by step of what you're doing, what's happening and what you're expecting?

jakobrosenberg avatar Jul 26 '22 20:07 jakobrosenberg

Upon a form submission, i'm trying to redirect to a success page which should contain the submitted informations. So i have setup a $goto on success to the page which is named like [id].svelte. this page contains <!-- routify:options name="tools.show" --> and i'm calling $goto('tools.show', {id: slug_number})

I would expect to be redirect to such page on success, what happens instead is i get navigated to such page, and then redirect to the same-level index.svelte file. if i browse back with the "back" arrow from the browser i land on the [id].svelte page correctly at the url foldername/slug_number. I tryed creating a reproducible to show you from the starter template but i am unable to reproduce the same ux flow. I should investigate further my project to understand what is causing the double navigation.

is this type of usage $goto('tools.show', {id: slug_number}) supposed to work and route me to foldername/slug_number? Thank you for your time

gianmarco27 avatar Jul 27 '22 10:07 gianmarco27

I would have expected that to work. Are you using Routify 2?

jakobrosenberg avatar Jul 29 '22 13:07 jakobrosenberg

Yes i'm using 2.18.8 After all turns out it was again a problem on my side. After the $goto call, more code from the originating page was still being executed causing the weird behaviour

gianmarco27 avatar Jul 29 '22 14:07 gianmarco27