import * as React from 'react'; import { InstantSearch, Hits, Highlight, SearchBox, RefinementList, CurrentRefinements, ClearRefinements, Pagination, Menu, Configure, Index } from 'react-instantsearch/dom'; import { Hit, connectRefinementList, connectMenu } from 'react-instantsearch-core'; // DOM // https://community.algolia.com/react-instantsearch/Getting_started.html () => { const App1 = () => ( ); const App2 = () => ( ); function Search() { return (
); } function Product({ hit }: { hit: Hit }) { return
{hit.name}
; } function Search2() { return (
); } function Product2({ hit }: { hit: Hit }) { return (
); } function Search3() { return (
); } function Search4() { return (
); } }; // https://community.algolia.com/react-instantsearch/guide//Highlighting_results.html () => { const Hit = ({ hit }: { hit: Hit }) => (

); function App() { return ( ); } }; // TODO // () => { // const CustomHighlight = connectHighlight( // ({ highlight, attribute, hit, highlightProperty }) => { // const parsedHit = highlight({ // attribute, // hit, // highlightProperty: '_highlightResult' // }); // const highlightedHits = parsedHit.map(part => { // if (part.isHighlighted) return {part.value}; // return part.value; // }); // return
{highlightedHits}
; // } // ); // const Hit = ({ hit }: { hit: Hit }) => ( //

// //

// ); // function App() { // return ( // // // // ); // } // }; // https://community.algolia.com/react-instantsearch/guide/i18n.html () => { const App = () => ( ); }; // https://community.algolia.com/react-instantsearch/guide/Sorting_and_filtering.html // TODO // () => { // const App = () => ( // // // // orderBy(items, ['label', 'count'], ['asc', 'desc']) // } // /> // // ); // }; // https://community.algolia.com/react-instantsearch/guide/Default_refinements.html () => { const App = () => ( ); }; // TODO // () => { // const VirtualMenu = connectMenu(() => null); // const App = () => ( // //
// // items.filter(item => item.currentRefinement !== 'Orange') // } // /> // // // //
//
// ); // }; // https://community.algolia.com/react-instantsearch/guide/Searching_in_Lists.html ; () => { // https://community.algolia.com/react-instantsearch/guide/Search_parameters.html // widgets ; }; (() => { function onSearchBoxChange(event: React.SyntheticEvent) { } function onSearchBoxReset(event: React.SyntheticEvent) { } function onSearchBoxSubmit(event: React.SyntheticEvent) { } } />; }); import { createInstantSearch } from 'react-instantsearch-dom/server'; // import { createServer } from 'http'; declare function createServer(handler: (req: any, res: any) => any): any; import { renderToString } from 'react-dom/server'; () => { // https://community.algolia.com/react-instantsearch/guide/Server-side_rendering.html // Now we create a dedicated `InstantSearch` component const { InstantSearch, findResultsState } = createInstantSearch(); class App extends React.Component { render() { return ( ); } } const server = createServer(async (req, res) => { const searchState = {query: 'chair'}; const resultsState = await findResultsState(App, {searchState}); const appInitialState = {searchState, resultsState}; const appAsString = renderToString(); res.send( `

Awesome server-side rendered search

${appAsString} ` ); }); };