import React, { useEffect } from 'react' import Head from 'next/head' import Link from 'next/link' import { logout } from '../utils/auth' import { getRandomSlogan } from '../utils/misc' import { editableWhenOnline } from '../utils/hooks' const Layout = ({ children }) => { const title = getRandomSlogan() const online = typeof window !== 'undefined' ? editableWhenOnline() : true useEffect(() => { if (window && 'navigator' in window && 'serviceWorker' in navigator) { window.addEventListener('load', () => { navigator.serviceWorker.register('/sw.js') }) } }, []) return {title}
{children}
{!online &&
Offline
} {/* language=CSS */}
} export default Layout