Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit 5f1976d

Browse files
authored
feat(router): force object form (#562)
* docs(routing): document full version of IS router, not shorthand in guide * docs(routing): only document object form * feat(router): force object form * docs(examples): use object form * fix(InstantSearch): no unreachable code * docs: split up in bullets Co-Authored-By: Haroenv <fingebimus@me.com>
1 parent 161782d commit 5f1976d

File tree

14 files changed

+173
-40
lines changed

14 files changed

+173
-40
lines changed

docs/src/advanced/vue-router-url-sync.md

+35-9
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,49 @@ githubSource: docs/src/advanced/vue-router-url-sync.md
1111

1212
> NOTE: this guide **has** been updated for v2
1313
14-
Currently there's three existing ways how to use InstantSearch routing.
1514

16-
The first option is putting `:routing="true"` on `ais-instant-search`. This will use the default serialising that doesn't lose any information, but might be a bit verbose
1715

18-
The second option is to put an object of configuration. This object can take `stateMapping`, with the functions `stateToRoute` and `routeToState` to serialise differently, but still use the default routing. This allows to rename things to make them easier to read, without touching how the serialising itself happens.
16+
The `routing` prop on `ais-instant-search` accepts an object. The simplest way to get started without customising URLs at all is the following:
1917

20-
Finally, you can also change the URL to use full URLs, rather than just the query string. You need to change the `router` key inside the `routing` object. You can import the default (history) router from `import {history} from 'instantsearch.js/es/lib/routers'`, and modify, like in InstantSearch JS.
18+
```vue
19+
<template>
20+
<ais-instant-search
21+
:routing="{
22+
router: historyRouter(),
23+
stateMapping: simpleMapping(),
24+
}"
25+
>
26+
<!-- Your search components go in here -->
27+
</ais-instant-search>
28+
</template>
2129
22-
[![Edit vue-instantsearch-app](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/q8pmz6n7lj?module=%2Fsrc%2FApp.vue)
30+
<script>
31+
import { history as historyRouter } from 'instantsearch.js/es/lib/routers';
32+
import { simple as simpleMapping } from 'instantsearch.js/es/lib/stateMappings';
2333
24-
All docs for InstantSearch routing configuration are [here](https://community.algolia.com/instantsearch.js/v2/guides/routing.html).
34+
export default {
35+
data() {
36+
return {
37+
historyRouter,
38+
simpleMapping,
39+
};
40+
},
41+
};
42+
</script>
43+
```
44+
45+
They're routing object contains two keys: `history` and `stateMapping`:
2546

26-
Finally an option is to use Vue Router. All previous examples will _work_ using Vue Router, as long as they don't conflict, as long as you don't try to do specific Vue Router things which are controlled by InstantSearch, since InstantSearch provided query strings won't be available to Vue Router, as soon as the routing changes from its initial deserialization.
47+
- **history**: used for writing and reading to the URL,
48+
- **stateMapping**: used for mapping the InstantSearch state towards the state that will be read and written to the URL.
2749

28-
## How **do** I use Vue Router?
50+
If you want to customise which things are written in the URL but don't want to customise how exactly the URL looks you will use state mapping. The way to do this is replacing the call to `stateMapping` with an object with the functions `stateToRoute` and `routeToState`.
2951

30-
If you have a Vue Router configuration that requires a synchronized use of the query parameters, or other parameters, as described in the InstantSearch guide, you need to write a custom "router" key for InstantSearch:
52+
If you also want to customise how the URL is read and written, for example when you are using Vue Router, you will override the behaviour of `router`. Note however that to use Vue Router, you don't **need** to synchronise InstantSearch routing to Vue Router routing, the only reason to do is if you are doing other router functions on your search page as well, and want to avoid conflicts when both are writing to the URL at the same time. To do this, you pass an object to the `router` key:
3153

3254
```js
55+
const router = this.router; /* get this from Vue Router */
56+
3357
const instantSearchRouting = {
3458
router: {
3559
read() {
@@ -102,3 +126,5 @@ const router = new Router({
102126
```
103127

104128
Note that the `qs` module is already used in InstantSearch, so this will not add to your bundle size, unless you use a different version.
129+
130+
All docs for InstantSearch routing configuration are [here](https://community.algolia.com/instantsearch.js/v2/guides/routing.html).

docs/src/components/InstantSearch.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Name | Type | Default | Description | Required
5353
`index-name` | String | | The index to target for the search | yes
5454
`searchFunction` | `(AlgoliaHelper) => void` | | A hook that will be called each time a search needs to be done, with the [helper](https://community.algolia.com/algoliasearch-helper-js/) as a parameter. It’s your responsibility to call `helper.search()`. This option allows you to avoid doing searches at page load for example. | no
5555
`stalled-search-delay` | Number | `200` | Time (in ms) before the search is considered unresponsive. Used to display a loading indicator. | no
56-
`routing` | Boolean or Object | `false` | Enable the default routing feature by passing `true`. More advanced usage is documented [here](https://community.algolia.com/instantsearch.js/v2/guides/routing.html). | no
56+
`routing` | Object | | documented [here](/advanced/vue-router-url-sync.html). | no
5757
class-names | Object | `{}` | Override class names | no
5858

5959
## Slots

docs/src/getting-started/migration.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ If you're using this, and have suggestions or questions, [please get in touch](h
160160

161161
3. Routing
162162

163-
Routing is not fully fleshed out yet. It's possible to set the `routing` prop to `true` or an object with the options, but it doesn't integrate with Vue Router yet at this point.
164-
165-
If you're using this, and have suggestions, [please get in touch](https://github.com/algolia/vue-instantsearch/issues/new?template=v2_feedback.md).
163+
You're now able to use routing in InstantSearch with, or without Vue Router. Read more on how to use that [here](/advanced/vue-router-url-sync.html).
166164

167165
4. changing props on `ais-instant-search`
168166

examples/default-theme/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"lint": "vue-cli-service lint"
99
},
1010
"dependencies": {
11+
"instantsearch.js": "^2.10.4",
1112
"vue": "^2.5.17",
1213
"vue-instantsearch": "2.0.0-alpha.3"
1314
},

examples/default-theme/src/App.vue

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ais-instant-search
44
:search-client="searchClient"
55
index-name="instant_search"
6-
:routing="true"
6+
:routing="routing"
77
>
88
<ais-configure :hitsPerPage="16" />
99

@@ -119,6 +119,9 @@
119119

120120
<script>
121121
import algoliasearch from 'algoliasearch/lite';
122+
import { history as historyRouter } from 'instantsearch.js/es/lib/routers';
123+
import { simple as simpleMapping } from 'instantsearch.js/es/lib/stateMappings';
124+
122125
import './App.css';
123126
124127
export default {
@@ -128,6 +131,10 @@ export default {
128131
'latency',
129132
'6be0576ff61c053d5f9a3225e2a90f76'
130133
),
134+
routing: {
135+
router: historyRouter(),
136+
stateMapping: simpleMapping(),
137+
}
131138
};
132139
},
133140
};

examples/default-theme/yarn.lock

+30-7
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ algoliasearch-helper@2.26.0:
11231123
qs "^6.5.1"
11241124
util "^0.10.3"
11251125

1126-
algoliasearch-helper@^2.26.1:
1126+
algoliasearch-helper@^2.26.0, algoliasearch-helper@^2.26.1:
11271127
version "2.26.1"
11281128
resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-2.26.1.tgz#75bd34f095e852d1bda483b8ebfb83c3c6e2852c"
11291129
integrity sha512-fQBZZXC3rac4wadRj5wA/gxy88Twb+GQF3n8foew8SAsqe9Q59PFq1y3j08pr6eNSRYkZJV7qMpe7ox5D27KOw==
@@ -1154,7 +1154,7 @@ algoliasearch@3.27.0:
11541154
semver "^5.1.0"
11551155
tunnel-agent "^0.6.0"
11561156

1157-
algoliasearch@^3.30.0:
1157+
algoliasearch@^3.27.0, algoliasearch@^3.30.0:
11581158
version "3.30.0"
11591159
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.30.0.tgz#355585e49b672e5f71d45b9c2b371ecdff129cd1"
11601160
integrity sha512-FuinyPgNn0MeAHm9pan6rLgY6driY3mcTo4AWNBMY1MUReeA5PQA8apV/3SNXqA5bbsuvMvmA0ZrVzrOmEeQTA==
@@ -1931,6 +1931,11 @@ classnames@2.2.5:
19311931
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d"
19321932
integrity sha1-+zgB1FNGdknvNgPH1hoCvRKb3m0=
19331933

1934+
classnames@^2.2.5:
1935+
version "2.2.6"
1936+
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
1937+
integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==
1938+
19341939
clean-css@4.2.x:
19351940
version "4.2.1"
19361941
resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.1.tgz#2d411ef76b8569b6d0c84068dabe85b0aa5e5c17"
@@ -3862,7 +3867,7 @@ hoek@5.x.x:
38623867
resolved "https://registry.yarnpkg.com/hoek/-/hoek-5.0.4.tgz#0f7fa270a1cafeb364a4b2ddfaa33f864e4157da"
38633868
integrity sha512-Alr4ZQgoMlnere5FZJsIyfIjORBqZll5POhDsF4q64dPuJR6rNxXdDxtHSQq8OXRurhmx+PWYEE8bXRROY8h0w==
38643869

3865-
hogan.js@3.0.2:
3870+
hogan.js@3.0.2, hogan.js@^3.0.2:
38663871
version "3.0.2"
38673872
resolved "https://registry.yarnpkg.com/hogan.js/-/hogan.js-3.0.2.tgz#4cd9e1abd4294146e7679e41d7898732b02c7bfd"
38683873
integrity sha1-TNnhq9QpQUbnZ55B14mHMrAse/0=
@@ -4155,6 +4160,24 @@ instantsearch.js@^2.10.2:
41554160
qs "6.5.1"
41564161
to-factory "1.0.0"
41574162

4163+
instantsearch.js@^2.10.4:
4164+
version "2.10.4"
4165+
resolved "https://registry.yarnpkg.com/instantsearch.js/-/instantsearch.js-2.10.4.tgz#446b1ce06eff52c86f195e761087950020cc7fee"
4166+
integrity sha512-hhGdYQJBejN4Xm1ElirNenD1BUsP6HE9HOoAII13psn1vXnKE89oQ7/3Z/fpVRBKM0P2KopXJZ5WVn2JFp7ZDQ==
4167+
dependencies:
4168+
algoliasearch "^3.27.0"
4169+
algoliasearch-helper "^2.26.0"
4170+
classnames "^2.2.5"
4171+
events "^1.1.0"
4172+
hogan.js "^3.0.2"
4173+
lodash "^4.17.5"
4174+
preact "^8.2.7"
4175+
preact-compat "^3.18.0"
4176+
preact-rheostat "^2.1.1"
4177+
prop-types "^15.5.10"
4178+
qs "^6.5.1"
4179+
to-factory "^1.0.0"
4180+
41584181
internal-ip@^3.0.1:
41594182
version "3.0.1"
41604183
resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-3.0.1.tgz#df5c99876e1d2eb2ea2d74f520e3f669a00ece27"
@@ -6165,7 +6188,7 @@ preact-compat@3.18.0:
61656188
prop-types "^15.5.8"
61666189
standalone-react-addons-pure-render-mixin "^0.1.1"
61676190

6168-
preact-compat@^3.17.0:
6191+
preact-compat@^3.17.0, preact-compat@^3.18.0:
61696192
version "3.18.4"
61706193
resolved "https://registry.yarnpkg.com/preact-compat/-/preact-compat-3.18.4.tgz#fbe76ddd30356c68e3ccde608107104946f2cf8d"
61716194
integrity sha512-aR5CvCIDerE2Y201ERVkWQdTAQKhKGNYujEk4tbyfQDInFTrnCCa3KCeGtULZrwy0PNRBjdQa2/Za7qv7ALNFg==
@@ -6183,7 +6206,7 @@ preact-render-to-string@^3.6.0, preact-render-to-string@^3.8.2:
61836206
dependencies:
61846207
pretty-format "^3.5.1"
61856208

6186-
preact-rheostat@2.1.1:
6209+
preact-rheostat@2.1.1, preact-rheostat@^2.1.1:
61876210
version "2.1.1"
61886211
resolved "https://registry.yarnpkg.com/preact-rheostat/-/preact-rheostat-2.1.1.tgz#45fcb4c2f4f7beb6dbd5e0f18f744655fc16ac7c"
61896212
integrity sha512-d03JgkpbjknALYl+zfNiJQ60sFd4A0YjnLCe/DB+rqKQck7jXpsW9RqSN0R50/lV8fEezhVCjq2WMPDDOKmwaA==
@@ -6203,7 +6226,7 @@ preact@8.2.7:
62036226
resolved "https://registry.yarnpkg.com/preact/-/preact-8.2.7.tgz#316249fb678cd5e93e7cee63cea7bfb62dbd6814"
62046227
integrity sha512-m34Ke8U32HyKRVzUOCAcaiIBLR2ye6syiuRclU5DxyixDPDFqdLbIElhERBrF6gDbPKQR+Vpv5bZ9CCbvN6pdQ==
62056228

6206-
preact@^8.2.5:
6229+
preact@^8.2.5, preact@^8.2.7:
62076230
version "8.3.1"
62086231
resolved "https://registry.yarnpkg.com/preact/-/preact-8.3.1.tgz#ed34f79d09edc5efd32a378a3416ef5dc531e3ac"
62096232
integrity sha512-s8H1Y8O9e+mOBo3UP1jvWqArPmjCba2lrrGLlq/0kN1XuIINUbYtf97iiXKxCuG3eYwmppPKnyW2DBrNj/TuTg==
@@ -7427,7 +7450,7 @@ to-arraybuffer@^1.0.0:
74277450
resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43"
74287451
integrity sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=
74297452

7430-
to-factory@1.0.0:
7453+
to-factory@1.0.0, to-factory@^1.0.0:
74317454
version "1.0.0"
74327455
resolved "https://registry.yarnpkg.com/to-factory/-/to-factory-1.0.0.tgz#8738af8bd97120ad1d4047972ada5563bf9479b1"
74337456
integrity sha1-hzivi9lxIK0dQEeXKtpVY7+UebE=

examples/ecommerce/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"dependencies": {
1111
"algoliasearch": "^3.30.0",
12+
"instantsearch.js": "^2.10.4",
1213
"vue": "^2.5.17",
1314
"vue-instantsearch": "2.0.0-alpha.3"
1415
},

examples/ecommerce/src/App.vue

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ais-instant-search
44
:search-client="searchClient"
55
index-name="instant_search"
6-
:routing="true"
6+
:routing="router"
77
>
88
<ais-configure :hitsPerPage="16" />
99

@@ -163,6 +163,9 @@
163163

164164
<script>
165165
import algoliasearch from 'algoliasearch/lite';
166+
import { history as historyRouter } from 'instantsearch.js/es/lib/routers';
167+
import { simple as simpleMapping } from 'instantsearch.js/es/lib/stateMappings';
168+
166169
import './App.css';
167170
168171
export default {
@@ -172,6 +175,10 @@ export default {
172175
'latency',
173176
'6be0576ff61c053d5f9a3225e2a90f76'
174177
),
178+
routing: {
179+
router: historyRouter(),
180+
stateMapping: simpleMapping(),
181+
}
175182
};
176183
},
177184
};

examples/ecommerce/yarn.lock

+30-7
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ algoliasearch-helper@2.26.0:
11191119
qs "^6.5.1"
11201120
util "^0.10.3"
11211121

1122-
algoliasearch-helper@^2.26.1:
1122+
algoliasearch-helper@^2.26.0, algoliasearch-helper@^2.26.1:
11231123
version "2.26.1"
11241124
resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-2.26.1.tgz#75bd34f095e852d1bda483b8ebfb83c3c6e2852c"
11251125
integrity sha512-fQBZZXC3rac4wadRj5wA/gxy88Twb+GQF3n8foew8SAsqe9Q59PFq1y3j08pr6eNSRYkZJV7qMpe7ox5D27KOw==
@@ -1150,7 +1150,7 @@ algoliasearch@3.27.0:
11501150
semver "^5.1.0"
11511151
tunnel-agent "^0.6.0"
11521152

1153-
algoliasearch@^3.30.0:
1153+
algoliasearch@^3.27.0, algoliasearch@^3.30.0:
11541154
version "3.30.0"
11551155
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.30.0.tgz#355585e49b672e5f71d45b9c2b371ecdff129cd1"
11561156
integrity sha512-FuinyPgNn0MeAHm9pan6rLgY6driY3mcTo4AWNBMY1MUReeA5PQA8apV/3SNXqA5bbsuvMvmA0ZrVzrOmEeQTA==
@@ -1927,6 +1927,11 @@ classnames@2.2.5:
19271927
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d"
19281928
integrity sha1-+zgB1FNGdknvNgPH1hoCvRKb3m0=
19291929

1930+
classnames@^2.2.5:
1931+
version "2.2.6"
1932+
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
1933+
integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==
1934+
19301935
clean-css@4.2.x:
19311936
version "4.2.1"
19321937
resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.1.tgz#2d411ef76b8569b6d0c84068dabe85b0aa5e5c17"
@@ -3832,7 +3837,7 @@ hoek@5.x.x:
38323837
resolved "https://registry.yarnpkg.com/hoek/-/hoek-5.0.4.tgz#0f7fa270a1cafeb364a4b2ddfaa33f864e4157da"
38333838
integrity sha512-Alr4ZQgoMlnere5FZJsIyfIjORBqZll5POhDsF4q64dPuJR6rNxXdDxtHSQq8OXRurhmx+PWYEE8bXRROY8h0w==
38343839

3835-
hogan.js@3.0.2:
3840+
hogan.js@3.0.2, hogan.js@^3.0.2:
38363841
version "3.0.2"
38373842
resolved "https://registry.yarnpkg.com/hogan.js/-/hogan.js-3.0.2.tgz#4cd9e1abd4294146e7679e41d7898732b02c7bfd"
38383843
integrity sha1-TNnhq9QpQUbnZ55B14mHMrAse/0=
@@ -4125,6 +4130,24 @@ instantsearch.js@^2.10.2:
41254130
qs "6.5.1"
41264131
to-factory "1.0.0"
41274132

4133+
instantsearch.js@^2.10.4:
4134+
version "2.10.4"
4135+
resolved "https://registry.yarnpkg.com/instantsearch.js/-/instantsearch.js-2.10.4.tgz#446b1ce06eff52c86f195e761087950020cc7fee"
4136+
integrity sha512-hhGdYQJBejN4Xm1ElirNenD1BUsP6HE9HOoAII13psn1vXnKE89oQ7/3Z/fpVRBKM0P2KopXJZ5WVn2JFp7ZDQ==
4137+
dependencies:
4138+
algoliasearch "^3.27.0"
4139+
algoliasearch-helper "^2.26.0"
4140+
classnames "^2.2.5"
4141+
events "^1.1.0"
4142+
hogan.js "^3.0.2"
4143+
lodash "^4.17.5"
4144+
preact "^8.2.7"
4145+
preact-compat "^3.18.0"
4146+
preact-rheostat "^2.1.1"
4147+
prop-types "^15.5.10"
4148+
qs "^6.5.1"
4149+
to-factory "^1.0.0"
4150+
41284151
internal-ip@^3.0.1:
41294152
version "3.0.1"
41304153
resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-3.0.1.tgz#df5c99876e1d2eb2ea2d74f520e3f669a00ece27"
@@ -6130,7 +6153,7 @@ preact-compat@3.18.0:
61306153
prop-types "^15.5.8"
61316154
standalone-react-addons-pure-render-mixin "^0.1.1"
61326155

6133-
preact-compat@^3.17.0:
6156+
preact-compat@^3.17.0, preact-compat@^3.18.0:
61346157
version "3.18.4"
61356158
resolved "https://registry.yarnpkg.com/preact-compat/-/preact-compat-3.18.4.tgz#fbe76ddd30356c68e3ccde608107104946f2cf8d"
61366159
integrity sha512-aR5CvCIDerE2Y201ERVkWQdTAQKhKGNYujEk4tbyfQDInFTrnCCa3KCeGtULZrwy0PNRBjdQa2/Za7qv7ALNFg==
@@ -6148,7 +6171,7 @@ preact-render-to-string@^3.6.0, preact-render-to-string@^3.8.2:
61486171
dependencies:
61496172
pretty-format "^3.5.1"
61506173

6151-
preact-rheostat@2.1.1:
6174+
preact-rheostat@2.1.1, preact-rheostat@^2.1.1:
61526175
version "2.1.1"
61536176
resolved "https://registry.yarnpkg.com/preact-rheostat/-/preact-rheostat-2.1.1.tgz#45fcb4c2f4f7beb6dbd5e0f18f744655fc16ac7c"
61546177
integrity sha512-d03JgkpbjknALYl+zfNiJQ60sFd4A0YjnLCe/DB+rqKQck7jXpsW9RqSN0R50/lV8fEezhVCjq2WMPDDOKmwaA==
@@ -6168,7 +6191,7 @@ preact@8.2.7:
61686191
resolved "https://registry.yarnpkg.com/preact/-/preact-8.2.7.tgz#316249fb678cd5e93e7cee63cea7bfb62dbd6814"
61696192
integrity sha512-m34Ke8U32HyKRVzUOCAcaiIBLR2ye6syiuRclU5DxyixDPDFqdLbIElhERBrF6gDbPKQR+Vpv5bZ9CCbvN6pdQ==
61706193

6171-
preact@^8.2.5:
6194+
preact@^8.2.5, preact@^8.2.7:
61726195
version "8.3.1"
61736196
resolved "https://registry.yarnpkg.com/preact/-/preact-8.3.1.tgz#ed34f79d09edc5efd32a378a3416ef5dc531e3ac"
61746197
integrity sha512-s8H1Y8O9e+mOBo3UP1jvWqArPmjCba2lrrGLlq/0kN1XuIINUbYtf97iiXKxCuG3eYwmppPKnyW2DBrNj/TuTg==
@@ -7398,7 +7421,7 @@ to-arraybuffer@^1.0.0:
73987421
resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43"
73997422
integrity sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=
74007423

7401-
to-factory@1.0.0:
7424+
to-factory@1.0.0, to-factory@^1.0.0:
74027425
version "1.0.0"
74037426
resolved "https://registry.yarnpkg.com/to-factory/-/to-factory-1.0.0.tgz#8738af8bd97120ad1d4047972ada5563bf9479b1"
74047427
integrity sha1-hzivi9lxIK0dQEeXKtpVY7+UebE=

examples/media/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"dependencies": {
1111
"algoliasearch": "3.30.0",
12+
"instantsearch.js": "^2.10.4",
1213
"vue": "^2.5.17",
1314
"vue-instantsearch": "2.0.0-alpha.3"
1415
},

examples/media/src/App.vue

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ais-instant-search
33
:search-client="searchClient"
44
index-name="movies"
5-
:routing="true"
5+
:routing="routing"
66
>
77
<header class="navbar">
88
<img src="https://res.cloudinary.com/hilnmyskv/image/upload/w_100,h_100,dpr_2.0//v1461180087/logo-instantsearchjs-avatar.png" width="40">
@@ -96,6 +96,9 @@
9696

9797
<script>
9898
import algoliasearch from 'algoliasearch/lite';
99+
import { history as historyRouter } from 'instantsearch.js/es/lib/routers';
100+
import { simple as simpleMapping } from 'instantsearch.js/es/lib/stateMappings';
101+
99102
import './App.css';
100103
101104
export default {
@@ -105,6 +108,10 @@ export default {
105108
'latency',
106109
'6be0576ff61c053d5f9a3225e2a90f76'
107110
),
111+
routing: {
112+
router: historyRouter(),
113+
stateMapping: simpleMapping(),
114+
}
108115
};
109116
},
110117
};

0 commit comments

Comments
 (0)