blob: 45048fab6bf2a4eeebe549ad05d4df2f18d72623 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/**
* Shared functions for Lunr and Google search.
*/
/**
* Check URL parameters for search queries.
*
* @returns
* The query string if it exists, or an empty string.
*/
export const getSearchQueryFromURL = () => {
return new URLSearchParams(window.location.search).get('q') || '';
};
/**
* Update URL parameters with search query strings.
*
* This allows users to copy a link to search result pages.
*/
export const updateURLParams = (query) => {
window.history.pushState(null, '', `${window.location.pathname}?q=${query}`);
};
|