2021-02-22 02:39:04 +00:00
|
|
|
import { Component } from "inferno";
|
|
|
|
import { Helmet } from "inferno-helmet";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { Provider } from "inferno-i18next";
|
|
|
|
import { Route, Switch } from "inferno-router";
|
|
|
|
import { GetSiteResponse } from "lemmy-js-client";
|
|
|
|
import { i18n } from "../../i18next";
|
|
|
|
import { routes } from "../../routes";
|
|
|
|
import { favIconPngUrl, favIconUrl } from "../../utils";
|
2021-02-22 02:39:04 +00:00
|
|
|
import { Footer } from "./footer";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { Navbar } from "./navbar";
|
2021-02-22 02:39:04 +00:00
|
|
|
import { NoMatch } from "./no-match";
|
|
|
|
import "./styles.scss";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { Theme } from "./theme";
|
2020-09-06 16:15:25 +00:00
|
|
|
|
2020-09-07 03:41:46 +00:00
|
|
|
export interface AppProps {
|
2020-12-24 01:58:27 +00:00
|
|
|
siteRes: GetSiteResponse;
|
2020-09-07 03:41:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class App extends Component<AppProps, any> {
|
2020-09-06 16:15:25 +00:00
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
}
|
|
|
|
render() {
|
2020-12-24 01:58:27 +00:00
|
|
|
let siteRes = this.props.siteRes;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<>
|
2020-09-07 15:32:07 +00:00
|
|
|
<Provider i18next={i18n}>
|
|
|
|
<div>
|
2021-08-20 02:56:18 +00:00
|
|
|
<Theme myUserInfo={siteRes.my_user} />
|
2020-12-24 01:58:27 +00:00
|
|
|
{siteRes &&
|
2020-12-24 22:05:57 +00:00
|
|
|
siteRes.site_view &&
|
2020-12-24 01:58:27 +00:00
|
|
|
this.props.siteRes.site_view.site.icon && (
|
2020-09-15 15:55:38 +00:00
|
|
|
<Helmet>
|
|
|
|
<link
|
|
|
|
id="favicon"
|
2021-03-25 15:58:29 +00:00
|
|
|
rel="shortcut icon"
|
2020-09-15 15:55:38 +00:00
|
|
|
type="image/x-icon"
|
2021-03-25 15:58:29 +00:00
|
|
|
href={this.props.siteRes.site_view.site.icon || favIconUrl}
|
|
|
|
/>
|
|
|
|
<link
|
|
|
|
rel="apple-touch-icon"
|
|
|
|
href={
|
|
|
|
this.props.siteRes.site_view.site.icon || favIconPngUrl
|
|
|
|
}
|
2020-09-15 15:55:38 +00:00
|
|
|
/>
|
|
|
|
</Helmet>
|
|
|
|
)}
|
2020-12-24 01:58:27 +00:00
|
|
|
<Navbar site_res={this.props.siteRes} />
|
2020-09-07 15:32:07 +00:00
|
|
|
<div class="mt-4 p-0 fl-1">
|
|
|
|
<Switch>
|
|
|
|
{routes.map(({ path, exact, component: C, ...rest }) => (
|
|
|
|
<Route
|
|
|
|
key={path}
|
|
|
|
path={path}
|
|
|
|
exact={exact}
|
|
|
|
render={props => <C {...props} {...rest} />}
|
|
|
|
/>
|
|
|
|
))}
|
2020-11-10 18:24:47 +00:00
|
|
|
<Route render={props => <NoMatch {...props} />} />
|
2020-09-07 15:32:07 +00:00
|
|
|
</Switch>
|
|
|
|
</div>
|
2020-12-24 01:58:27 +00:00
|
|
|
<Footer site={this.props.siteRes} />
|
2020-09-06 16:15:25 +00:00
|
|
|
</div>
|
2020-09-07 15:32:07 +00:00
|
|
|
</Provider>
|
2020-09-06 16:15:25 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|