manifold/web/pages/index.tsx
2021-12-18 23:59:42 -06:00

29 lines
641 B
TypeScript

import React from 'react'
import { useUser } from '../hooks/use-user'
import Markets from './markets'
import LandingPage from './landing-page'
import { Contract, listAllContracts } from '../lib/firebase/contracts'
export async function getStaticProps() {
const contracts = await listAllContracts().catch((_) => [])
return {
props: {
contracts,
},
revalidate: 60, // regenerate after a minute
}
}
const Home = (props: { contracts: Contract[] }) => {
const user = useUser()
if (user === undefined) return <></>
return user ? <Markets contracts={props.contracts} /> : <LandingPage />
}
export default Home