Handle url query parameter
Hey Gottwik, firstly thanks for making enduro! It's pretty nice to work with!
Usage question:
Assuming I have a url: mysite.com/?tag=test
This will render the index page. In the UI if there is a tag I would like to filter a list of based on that tag (with some support from Hanldebars).
Do you support something like this already? Could you give some hints towards which direction to think to solve this issue?
Hey Diolor,
The challenges that you will have to overcome before you can achieve your business requirement:
-
Ensuring EnduroJs can serve the page with query string. Using "enduro dev" is fine but once you start using "enduro start" aka production setup, it will throw an error as it will start to look at "_generated" static files. The error would look something like this (File not found .... _generated\job-search?s=&loc=&cat=&subcat=\index.html)
-
Read the query string and deliver the HTML accordingly (complete HTML from the server side) or modify DOM (partial HTML from the server side and update the remaining HTML from the client side)
Solutions:
-
You can solve the first issue by creating a custom route to ensure that URL with query string can be served appropriately. You can look at the following link https://github.com/Gottwik/Enduro/issues/236 for the sample code.
-
I am not quite sure how you would achieve complete HTML from the server side, as by default Enduro would generate static HTML to serve for production setup. So there might be lot of changes required. Personally I felt to achieve partial HTML from server side (which basically the normal way to create page in Enduro) and update DOM partially through client side using jQuery AJAX or Vue.js would be easier approach.
-Steven