|
| 1 | +import 'instantsearch.css/themes/algolia-min.css' |
| 2 | +import React from 'react' |
| 3 | +import { |
| 4 | + InstantSearch, |
| 5 | + InfiniteHits, |
| 6 | + SearchBox, |
| 7 | + Stats, |
| 8 | + Highlight, |
| 9 | + ClearRefinements, |
| 10 | + RefinementList, |
| 11 | +} from 'react-instantsearch-dom' |
| 12 | +import { instantMeiliSearch } from '../../../../../src/index' |
| 13 | + |
| 14 | +const searchClient = instantMeiliSearch('http://localhost:7700', 'masterKey', { |
| 15 | + primaryKey: 'id', |
| 16 | + keepZeroFacets: true, |
| 17 | +}) |
| 18 | + |
| 19 | +const SingleIndex = () => ( |
| 20 | + <div className="ais-InstantSearch"> |
| 21 | + <h1>Meilisearch + React InstantSearch</h1> |
| 22 | + <h2>Search in movies</h2> |
| 23 | + |
| 24 | + <InstantSearch indexName="movies" searchClient={searchClient}> |
| 25 | + <Stats /> |
| 26 | + <div className="left-panel"> |
| 27 | + <ClearRefinements /> |
| 28 | + <h2>Genres</h2> |
| 29 | + <RefinementList attribute="genres" /> |
| 30 | + <h2>Players</h2> |
| 31 | + <RefinementList attribute="color" /> |
| 32 | + <h2>Platforms</h2> |
| 33 | + <RefinementList attribute="platforms" /> |
| 34 | + </div> |
| 35 | + <div className="right-panel"> |
| 36 | + <SearchBox /> |
| 37 | + <InfiniteHits hitComponent={Hit} /> |
| 38 | + </div> |
| 39 | + </InstantSearch> |
| 40 | + </div> |
| 41 | +) |
| 42 | + |
| 43 | +const Hit = ({ hit }) => { |
| 44 | + return ( |
| 45 | + <div key={hit.id}> |
| 46 | + <div className="hit-name"> |
| 47 | + <Highlight attribute="title" hit={hit} /> |
| 48 | + </div> |
| 49 | + <div className="hit-name"> |
| 50 | + <Highlight attribute="genres" hit={hit} /> |
| 51 | + </div> |
| 52 | + <div className="hit-name"> |
| 53 | + <Highlight attribute="color" hit={hit} /> |
| 54 | + </div> |
| 55 | + <div className="hit-name"> |
| 56 | + <Highlight attribute="platforms" hit={hit} /> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + ) |
| 60 | +} |
| 61 | + |
| 62 | +export default SingleIndex |
0 commit comments