994089fcc2
Converted to TypeScript to match Contribution docs, and updated/simplified the example. - Replaced stylesheets in Head component with imported styles - Removed `style-loader`, `css-loader`, `cross-env`, `prop-types` packages - Removed custom webpack config ## Documentation / Examples - [X] Make sure the linting passes by running `pnpm build && pnpm lint` - [X] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
10 lines
427 B
TypeScript
10 lines
427 B
TypeScript
import type { SearchState } from 'react-instantsearch-core'
|
|
import qs from 'qs'
|
|
|
|
export const createURL = (state: SearchState) => `?${qs.stringify(state)}`
|
|
|
|
export const pathToSearchState = (path: string) =>
|
|
path.includes('?') ? qs.parse(path.substring(path.indexOf('?') + 1)) : {}
|
|
|
|
export const searchStateToURL = (searchState: SearchState) =>
|
|
searchState ? `${window.location.pathname}?${qs.stringify(searchState)}` : ''
|