main-site/components/layout.tsx

45 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-12-17 23:40:52 +00:00
import PageFooter from './footer';
import PageNavbar from './navbar';
import Script from 'next/script';
import { Page, Main } from './styles/generic';
2022-12-18 22:21:38 +00:00
import useWindowSize from './windowsize';
2022-12-03 20:02:13 +00:00
const Layout = ({ children }: { children: React.ReactNode }) => {
2022-12-18 22:21:38 +00:00
const isMobile = useWindowSize();
2022-12-18 22:21:38 +00:00
let ret: JSX.Element;
if(isMobile) {
ret = (
2022-12-19 20:51:51 +00:00
<Page mobile={isMobile}>
2022-12-18 22:21:38 +00:00
<Script id="matomo_analytics"
defer src='https://static.cloudflareinsights.com/beacon.min.js'
data-cf-beacon='{"token": "826fc083aa86417890c0ceb3e0a597fa"}'>
</Script>
<PageNavbar mobile={isMobile}/>
<Main>
{children}
</Main>
</Page>
);
}
else {
ret = (
<Page>
<Script id="matomo_analytics"
defer src='https://static.cloudflareinsights.com/beacon.min.js'
data-cf-beacon='{"token": "826fc083aa86417890c0ceb3e0a597fa"}'>
</Script>
<PageNavbar mobile={isMobile}/>
<Main>
{children}
</Main>
<PageFooter />
</Page>
);
}
return ret;
2022-12-03 20:02:13 +00:00
}
export default Layout;