-
Notifications
You must be signed in to change notification settings - Fork 371
/
Copy pathRouter.tsx
70 lines (65 loc) · 2.39 KB
/
Router.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import * as React from "react";
import { Switch, Route, useLocation } from "react-router-dom";
import Root from "./pages/home";
import ElasticsearchBasic from "./pages/elasticsearch-basic";
import ElasticsearchProductionReady from "./pages/elasticsearch-production-ready";
import Engines from "./pages/engines";
import SiteSearch from "./pages/site-search";
import SearchAsYouType from "./pages/search-as-you-type";
import CustomizingStylesAndHtml from "./pages/customizing-styles-and-html";
import SearchBarInHeaderIndex from "./pages/search-bar-in-header/index";
import SearchBarInHeaderSearch from "./pages/search-bar-in-header/search";
import EcommerceHome from "./pages/ecommerce";
import EcommerceSearch from "./pages/ecommerce/Search";
import EcommerceCategory from "./pages/ecommerce/Category";
import ListingPage from "./pages/ecommerce/ListingPage";
export default function Router() {
const location = useLocation();
const isHomePage = location.pathname === "/";
return (
<div className={`${isHomePage ? "App" : "ExampleApp mx-auto"}`}>
<Switch>
<Route exact path="/" component={Root} />
{/* Connectors */}
<Route
exact
path="/elasticsearch-basic"
component={ElasticsearchBasic}
/>
<Route
exact
path="/elasticsearch-production-ready"
component={ElasticsearchProductionReady}
/>
<Route exact path="/site-search" component={SiteSearch} />
<Route exact path="/engines" component={Engines} />
{/* Examples */}
<Route exact path="/search-as-you-type" component={SearchAsYouType} />
<Route
exact
path="/customizing-styles-and-html"
component={CustomizingStylesAndHtml}
/>
<Route
exact
path="/search-bar-in-header"
component={SearchBarInHeaderIndex}
/>
<Route
exact
path="/search-bar-in-header/search"
component={SearchBarInHeaderSearch}
/>
{/* Use cases */}
<Route exact path="/ecommerce/" component={EcommerceHome} />
<Route exact path="/ecommerce/search" component={EcommerceSearch} />
<Route exact path="/ecommerce/all" component={ListingPage} />
<Route
exact
path="/ecommerce/category/:category"
component={EcommerceCategory}
/>
</Switch>
</div>
);
}