tldraw/pages/index.tsx

33 lines
725 B
TypeScript
Raw Normal View History

import Head from 'next/head'
import dynamic from 'next/dynamic'
2021-06-20 12:35:47 +00:00
import { GetServerSideProps } from 'next'
import { getSession } from 'next-auth/client'
const Editor = dynamic(() => import('components/editor'), { ssr: false })
2021-05-09 12:03:39 +00:00
2021-06-21 21:35:28 +00:00
export default function Home(): JSX.Element {
2021-05-09 13:04:42 +00:00
return (
<>
<Head>
<title>tldraw</title>
</Head>
2021-07-07 13:02:48 +00:00
<Editor roomId="home" />
</>
2021-05-09 13:04:42 +00:00
)
2021-05-09 12:03:39 +00:00
}
2021-06-20 12:35:47 +00:00
export const getServerSideProps: GetServerSideProps = async (context) => {
const session = await getSession(context)
2021-07-07 14:42:17 +00:00
if (!session?.user && process.env.NODE_ENV !== 'development') {
2021-06-20 12:35:47 +00:00
context.res.setHeader('Location', `/sponsorware`)
context.res.statusCode = 307
}
return {
props: {
session,
},
}
}