|
1 | 1 | import { instantMeiliSearch } from '../../../src/index' |
| 2 | +import injectScript from 'scriptjs' |
2 | 3 |
|
3 | | -const search = instantsearch({ |
4 | | - indexName: 'steam-video-games', |
5 | | - searchClient: instantMeiliSearch( |
6 | | - 'https://demo-steam.meilisearch.com', |
7 | | - '90b03f9c47d0f321afae5ae4c4e4f184f53372a2953ab77bca679ff447ecc15c', |
8 | | - { |
9 | | - limitPerRequest: 30, |
10 | | - } |
11 | | - ), |
12 | | -}) |
13 | | - |
14 | | -search.addWidgets([ |
15 | | - instantsearch.widgets.sortBy({ |
16 | | - container: '#sort-by', |
17 | | - items: [ |
18 | | - { value: 'steam-video-games', label: 'Relevant' }, |
19 | | - { |
20 | | - value: 'steam-video-games:recommendationCount:desc', |
21 | | - label: 'Most Recommended', |
| 4 | +injectScript( |
| 5 | + 'https://maps.googleapis.com/maps/api/js?v=quarterly&key=AIzaSyBNrL9pJHScT2Xma6OdhyVZLBGO9v7JcAA', |
| 6 | + () => { |
| 7 | + const search = instantsearch({ |
| 8 | + indexName: 'steam-video-games', |
| 9 | + searchClient: instantMeiliSearch( |
| 10 | + 'https://demo-steam.meilisearch.com', |
| 11 | + '90b03f9c47d0f321afae5ae4c4e4f184f53372a2953ab77bca679ff447ecc15c', |
| 12 | + { |
| 13 | + limitPerRequest: 30, |
| 14 | + } |
| 15 | + ), |
| 16 | + searchFunction: function (helper) { |
| 17 | + console.log(JSON.stringify()) |
| 18 | + helper.setQueryParameter('aroundRadius', 75000) |
| 19 | + helper.setQueryParameter('aroundLatLngViaIP', true) |
| 20 | + // helper.setQueryParameter('aroundRadius', somevalue); |
| 21 | + helper.search() |
22 | 22 | }, |
23 | | - { |
24 | | - value: 'steam-video-games:recommendationCount:asc', |
25 | | - label: 'Least Recommended', |
| 23 | + urlSync: { |
| 24 | + trackedParameters: [ |
| 25 | + 'attribute:*', |
| 26 | + 'query', |
| 27 | + 'page', |
| 28 | + 'hitsPerPage', |
| 29 | + 'aroundLatLngViaIP', |
| 30 | + 'aroundRadius', |
| 31 | + ], |
26 | 32 | }, |
27 | | - ], |
28 | | - }), |
29 | | - instantsearch.widgets.searchBox({ |
30 | | - container: '#searchbox', |
31 | | - }), |
32 | | - instantsearch.widgets.clearRefinements({ |
33 | | - container: '#clear-refinements', |
34 | | - }), |
35 | | - instantsearch.widgets.refinementList({ |
36 | | - container: '#genres-list', |
37 | | - attribute: 'genres', |
38 | | - }), |
39 | | - instantsearch.widgets.refinementList({ |
40 | | - container: '#players-list', |
41 | | - attribute: 'players', |
42 | | - }), |
43 | | - instantsearch.widgets.refinementList({ |
44 | | - container: '#platforms-list', |
45 | | - attribute: 'platforms', |
46 | | - }), |
47 | | - instantsearch.widgets.configure({ |
48 | | - hitsPerPage: 6, |
49 | | - attributesToSnippet: ['description:150'], |
50 | | - }), |
51 | | - instantsearch.widgets.refinementList({ |
52 | | - container: '#misc-list', |
53 | | - attribute: 'misc', |
54 | | - }), |
55 | | - instantsearch.widgets.hits({ |
56 | | - container: '#hits', |
57 | | - templates: { |
58 | | - item: ` |
59 | | - <div> |
60 | | - <div class="hit-name"> |
61 | | - {{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}} |
62 | | - </div> |
63 | | - <img src="{{image}}" align="left" /> |
64 | | - <div class="hit-name"> |
65 | | - {{#helpers.highlight}}{ "attribute": "description" }{{/helpers.highlight}} |
66 | | - </div> |
67 | | - <div class="hit-info">price: {{price}}</div> |
68 | | - <div class="hit-info">release date: {{releaseDate}}</div> |
69 | | - <div class="hit-info">Recommendation: {{recommendationCount}}</div> |
70 | | - </div> |
71 | | - `, |
72 | | - }, |
73 | | - }), |
74 | | - instantsearch.widgets.pagination({ |
75 | | - container: '#pagination', |
76 | | - }), |
77 | | -]) |
| 33 | + }) |
| 34 | + |
| 35 | + search.addWidgets([ |
| 36 | + instantsearch.widgets.sortBy({ |
| 37 | + container: '#sort-by', |
| 38 | + items: [ |
| 39 | + { value: 'steam-video-games', label: 'Relevant' }, |
| 40 | + { |
| 41 | + value: 'steam-video-games:recommendationCount:desc', |
| 42 | + label: 'Most Recommended', |
| 43 | + }, |
| 44 | + { |
| 45 | + value: 'steam-video-games:recommendationCount:asc', |
| 46 | + label: 'Least Recommended', |
| 47 | + }, |
| 48 | + ], |
| 49 | + }), |
| 50 | + instantsearch.widgets.searchBox({ |
| 51 | + container: '#searchbox', |
| 52 | + }), |
| 53 | + instantsearch.widgets.clearRefinements({ |
| 54 | + container: '#clear-refinements', |
| 55 | + }), |
| 56 | + instantsearch.widgets.refinementList({ |
| 57 | + container: '#genres-list', |
| 58 | + attribute: 'genres', |
| 59 | + }), |
| 60 | + instantsearch.widgets.refinementList({ |
| 61 | + container: '#players-list', |
| 62 | + attribute: 'players', |
| 63 | + }), |
| 64 | + instantsearch.widgets.refinementList({ |
| 65 | + container: '#platforms-list', |
| 66 | + attribute: 'platforms', |
| 67 | + }), |
| 68 | + instantsearch.widgets.configure({ |
| 69 | + hitsPerPage: 6, |
| 70 | + attributesToSnippet: ['description:150'], |
| 71 | + }), |
| 72 | + instantsearch.widgets.refinementList({ |
| 73 | + container: '#misc-list', |
| 74 | + attribute: 'misc', |
| 75 | + }), |
| 76 | + instantsearch.widgets.geoSearch({ |
| 77 | + container: '#maps', |
| 78 | + googleReference: window.google, |
| 79 | + enableRefineControl: true, |
| 80 | + enableRefineOnMapMove: false, |
| 81 | + initialPosition: { |
| 82 | + lat: 45.7597786530353, |
| 83 | + lng: 4.843585698860502, |
| 84 | + }, |
| 85 | + }), |
| 86 | + instantsearch.widgets.hits({ |
| 87 | + container: '#hits', |
| 88 | + templates: { |
| 89 | + item: ` |
| 90 | + <div> |
| 91 | + <div class="hit-name"> |
| 92 | + {{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}} |
| 93 | + </div> |
| 94 | + <img src="{{image}}" align="left" /> |
| 95 | + <div class="hit-name"> |
| 96 | + {{#helpers.highlight}}{ "attribute": "description" }{{/helpers.highlight}} |
| 97 | + </div> |
| 98 | + <div class="hit-info">price: {{price}}</div> |
| 99 | + <div class="hit-info">release date: {{releaseDate}}</div> |
| 100 | + <div class="hit-info">Recommendation: {{recommendationCount}}</div> |
| 101 | + </div> |
| 102 | + `, |
| 103 | + }, |
| 104 | + }), |
| 105 | + instantsearch.widgets.pagination({ |
| 106 | + container: '#pagination', |
| 107 | + }), |
| 108 | + ]) |
78 | 109 |
|
79 | | -search.start() |
| 110 | + search.start() |
| 111 | + } |
| 112 | +) |
0 commit comments