Using searching files is at /search.

This commit is contained in:
Roland 2024-02-12 12:12:07 -07:00
parent f7f2627e79
commit 407d60c074
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 5 additions and 3 deletions

View file

@ -164,7 +164,8 @@ export function useSearchSuggestions(defaultSearchStr, defaultTagNames) {
{
title: newSuggestions.fileGroups.toString(),
type: 'files',
location: getLocationStr({q: searchStr})
// Add search query onto current location.
location: getLocationStr({q: encodeURIComponent(searchStr)}, '/search')
}
]
};
@ -179,6 +180,7 @@ export function useSearchSuggestions(defaultSearchStr, defaultTagNames) {
if (newSuggestions && zimSum > 0) {
results.zimsSum = {
name: 'Zims', results: [
// Navigating to Zims is not relative. We don't want to keep filters or other extra params.
{title: zimSum.toString(), type: 'zims', location: `/search/zim?q=${encodeURIComponent(searchStr)}`}
],
};

View file

@ -132,10 +132,10 @@ export const useQuery = () => {
setQuery(newQuery);
}
const getLocationStr = (newSearchParams) => {
const getLocationStr = (newSearchParams, pathname) => {
// Get the current location, but with new params appended.
const newQuery = createSearchParams(getQuery(newSearchParams));
return `${location.pathname}?${newQuery.toString()}`
return `${pathname || location.pathname}?${newQuery.toString()}`
}
return {searchParams, setSearchParams, setQuery, updateQuery, getLocationStr}