forked from mirrorz-org/mirrorz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoot.tsx
87 lines (84 loc) · 2.8 KB
/
Root.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React, { useMemo } from "react";
import { useTranslation } from 'react-i18next';
import {
BrowserRouter as Router,
Switch,
Route,
NavLink,
} from "react-router-dom";
import Mirrors from "./Mirrors";
import ISO from "./ISO";
import Site from "./Site";
import About from "./About";
import Debug from "./Debug";
import Monitor from "./Monitor";
import { useIsoInfoList, useMirrorsList, useMirrorzSites, useSitesList } from "./hooks";
import { Page404 } from "./404";
// eslint-disable-next-line react/display-name
export default React.memo(() => {
const { t, i18n } = useTranslation();
const mirrorz = useMirrorzSites();
const mirrorzList = useMemo(() => Object.values(mirrorz), [mirrorz]);
const mirrorsList = useMirrorsList(mirrorz);
const isoinfoList = useIsoInfoList(mirrorz);
const siteList = useSitesList(mirrorz);
return (
<Router>
<div id="app-container">
<div className="sidebar">
<NavLink
to="/"
activeClassName="active"
isActive={(_, location) => {
if (
location.pathname === "/" ||
(!location.pathname.startsWith("/list") &&
!location.pathname.startsWith("/site") &&
!location.pathname.startsWith("/about") &&
!location.pathname.startsWith("/debug") &&
!location.pathname.startsWith("/monitor"))
) {
return true;
}
return false;
}}
>
<img src="/static/img/mirrorz.svg" className="sidebar-logo" alt="ISO" />
</NavLink>
<NavLink to="/list" activeClassName="active">
<h2 dangerouslySetInnerHTML={{__html: t("list.list")}} />
</NavLink>
<NavLink to="/site" activeClassName="active">
<h2 dangerouslySetInnerHTML={{__html: t("site.site")}} />
</NavLink>
<NavLink to="/about" activeClassName="active">
<h2>{t("about.about")}</h2>
</NavLink>
</div>
<main>
<Switch>
<Route path="/list/:filter?" exact>
<Mirrors mirrors={mirrorsList} />
</Route>
<Route path="/site/:siteSlug?/:statusFilter?" exact>
<Site site={siteList} />
</Route>
<Route path="/about" exact>
<About site={siteList} />
</Route>
<Route path="/debug" exact>
<Debug mirrorz={mirrorzList} />
</Route>
<Route path="/monitor" exact>
<Monitor />
</Route>
<Route path={["/", "/:category?/:distro?"]} exact>
<ISO isoinfo={isoinfoList} />
</Route>
<Page404 />
</Switch>
</main>
</div>
</Router>
);
});