I'm creating a search engine with multiple filters users can pick, along with a query. All of those are optional and add up to the filtered result set.
So all these cases are possible and being properly stored in an object of keywords:
- Searching with a query
- Searching by country (without specifying any query)
- Searching by type (without specifying any query)
- Searching a query with a country and a type
- ...
What would be the best way of handling this with Vue Router? I want the search route to be updated with whatever filters are picked.
As far as I can tell I can't use multiple optional parameters and unless I specify all possible combinations (which is a bit silly) like:
export const routes = [
{ path: '/search', name: 'search', component: Search, children: [
{ path: 'query/:query, component: Search },
{ path: 'type/:type', component: Search },
{ path: 'country/:country', component: Search },
...
]},
... I don't see any other way of solving the problem. What would be the best option?