2021-11-26 15:14:10 +00:00
|
|
|
import type { GetServerSideProps } from 'next'
|
2021-12-22 00:14:38 +00:00
|
|
|
import { getSession } from 'next-auth/react'
|
2022-03-24 09:05:35 +00:00
|
|
|
import dynamic from 'next/dynamic'
|
2021-09-06 13:37:48 +00:00
|
|
|
import Head from 'next/head'
|
2022-01-10 16:36:28 +00:00
|
|
|
import { useRouter } from 'next/router'
|
2022-03-24 09:05:35 +00:00
|
|
|
import { FC, useMemo } from 'react'
|
2021-09-04 09:14:47 +00:00
|
|
|
|
2022-05-14 13:15:55 +00:00
|
|
|
const Editor = dynamic(() => import('components/Editor'), { ssr: false }) as any
|
2021-09-04 12:02:13 +00:00
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
interface PageProps {
|
|
|
|
isUser: boolean
|
|
|
|
isSponsor: boolean
|
|
|
|
}
|
|
|
|
|
2022-03-24 09:05:35 +00:00
|
|
|
const Home: FC<PageProps> = ({ isUser, isSponsor }) => {
|
2022-01-10 16:36:28 +00:00
|
|
|
const { query } = useRouter()
|
|
|
|
const isExportMode = useMemo(() => 'exportMode' in query, [query])
|
|
|
|
|
2021-09-06 13:37:48 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Head>
|
2021-11-16 16:31:50 +00:00
|
|
|
<title>tldraw</title>
|
2021-09-06 13:37:48 +00:00
|
|
|
</Head>
|
2022-01-10 16:36:28 +00:00
|
|
|
<Editor id="home" isUser={isUser} isSponsor={isSponsor} showUI={!isExportMode} />
|
2021-09-06 13:37:48 +00:00
|
|
|
</>
|
|
|
|
)
|
2021-09-04 12:02:13 +00:00
|
|
|
}
|
|
|
|
|
2022-03-24 09:05:35 +00:00
|
|
|
export default Home
|
|
|
|
|
2021-09-04 12:02:13 +00:00
|
|
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
|
|
const session = await getSession(context)
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
2021-11-19 14:33:15 +00:00
|
|
|
isUser: session?.user ? true : false,
|
2022-01-10 16:36:28 +00:00
|
|
|
isSponsor: session?.isSponsor || false,
|
2021-09-04 12:02:13 +00:00
|
|
|
},
|
|
|
|
}
|
2021-08-10 16:12:55 +00:00
|
|
|
}
|