tldraw/apps/www/pages/index.tsx

41 lines
984 B
TypeScript
Raw Normal View History

import type { GetServerSideProps } from 'next'
import { getSession } from 'next-auth/react'
import dynamic from 'next/dynamic'
2021-09-06 13:37:48 +00:00
import Head from 'next/head'
import { useRouter } from 'next/router'
import { FC, useMemo } from 'react'
const Editor = dynamic(() => import('components/Editor'), { ssr: false }) as any
2021-09-04 12:02:13 +00:00
interface PageProps {
isUser: boolean
isSponsor: boolean
}
const Home: FC<PageProps> = ({ isUser, isSponsor }) => {
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>
<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
}
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,
isSponsor: session?.isSponsor || false,
2021-09-04 12:02:13 +00:00
},
}
2021-08-10 16:12:55 +00:00
}