mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-25 20:48:50 +02:00
fix(v2): use base url to navigate to search page (#2838)
* fix: consider baseUrl
Add baseUrl to search page query URL.
* fix: use `useBaseUrl()`
* Revert "fix: use `useBaseUrl()`"
This reverts commit 72b319a293
.
* fix: add link to PR
This commit is contained in:
parent
c0c7457e01
commit
e63c468b0f
1 changed files with 4 additions and 1 deletions
|
@ -7,12 +7,14 @@
|
||||||
|
|
||||||
import {useHistory, useLocation} from '@docusaurus/router';
|
import {useHistory, useLocation} from '@docusaurus/router';
|
||||||
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
||||||
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
|
|
||||||
const SEARCH_PARAM_QUERY = 'q';
|
const SEARCH_PARAM_QUERY = 'q';
|
||||||
|
|
||||||
function useSearchQuery() {
|
function useSearchQuery() {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
const {siteConfig: {baseUrl} = {}} = useDocusaurusContext();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
searchValue:
|
searchValue:
|
||||||
|
@ -33,7 +35,8 @@ function useSearchQuery() {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
navigateToSearchPage: (searchValue) => {
|
navigateToSearchPage: (searchValue) => {
|
||||||
history.push(`/search?q=${searchValue}`);
|
// Refer to https://github.com/facebook/docusaurus/pull/2838
|
||||||
|
history.push(`${baseUrl}search?q=${searchValue}`);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue