pleroma/app/soapbox/features/public-layout/index.tsx

51 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-05-12 11:53:41 -07:00
import React from 'react';
import { Switch, Route, Redirect } from 'react-router-dom';
import LandingGradient from 'soapbox/components/landing-gradient';
2022-12-29 08:42:54 -08:00
import { useAppSelector, useSoapboxConfig } from 'soapbox/hooks';
2022-05-12 11:53:41 -07:00
import { isStandalone } from 'soapbox/utils/state';
import AboutPage from '../about';
2022-11-15 11:00:40 -08:00
import LandingPage from '../landing-page';
2022-05-12 11:53:41 -07:00
import Footer from './components/footer';
import Header from './components/header';
const PublicLayout = () => {
const standalone = useAppSelector((state) => isStandalone(state));
2022-12-29 08:42:54 -08:00
const soapboxConfig = useSoapboxConfig();
const shouldRedirectFromRoot = soapboxConfig.redirectRootNoLogin && !soapboxConfig.redirectRootNoLogin.match(/^\/?$/);
2022-05-12 11:53:41 -07:00
if (standalone) {
return <Redirect to='/login/external' />;
}
return (
<div className='h-full'>
<LandingGradient />
<div className='flex flex-col h-screen'>
<div className='flex-shrink-0'>
<Header />
<div className='relative'>
<Switch>
2022-12-29 08:42:54 -08:00
{shouldRedirectFromRoot ? (
<Redirect exact path='/' to={soapboxConfig.redirectRootNoLogin} />
) : (
<Route exact path='/' component={LandingPage} />
)}
2022-05-12 11:53:41 -07:00
<Route exact path='/about/:slug?' component={AboutPage} />
</Switch>
</div>
</div>
<Footer />
</div>
</div>
);
};
export default PublicLayout;