Fetch markets client side on explore page (to avoid vercel 5MB limit for static props)
This commit is contained in:
parent
ca8420d61b
commit
7e9007aad1
|
@ -2,26 +2,16 @@ import {
|
||||||
ContractsGrid,
|
ContractsGrid,
|
||||||
SearchableGrid,
|
SearchableGrid,
|
||||||
} from '../components/contract/contracts-list'
|
} from '../components/contract/contracts-list'
|
||||||
|
import { LoadingIndicator } from '../components/loading-indicator'
|
||||||
import { Page } from '../components/page'
|
import { Page } from '../components/page'
|
||||||
import { SEO } from '../components/SEO'
|
import { SEO } from '../components/SEO'
|
||||||
import { Title } from '../components/title'
|
import { Title } from '../components/title'
|
||||||
import { useContracts } from '../hooks/use-contracts'
|
import { useContracts } from '../hooks/use-contracts'
|
||||||
import { Contract, listAllContracts } from '../lib/firebase/contracts'
|
import { Contract } from '../lib/firebase/contracts'
|
||||||
|
|
||||||
export async function getStaticProps() {
|
|
||||||
const contracts = await listAllContracts().catch((_) => [])
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
contracts,
|
|
||||||
},
|
|
||||||
|
|
||||||
revalidate: 60, // regenerate after a minute
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Rename endpoint to "Explore"
|
// TODO: Rename endpoint to "Explore"
|
||||||
export default function Markets(props: { contracts: Contract[] }) {
|
export default function Markets() {
|
||||||
const contracts = useContracts() ?? props.contracts ?? []
|
const contracts = useContracts()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
|
@ -30,12 +20,11 @@ export default function Markets(props: { contracts: Contract[] }) {
|
||||||
description="Discover what's new, trending, or soon-to-close. Or search among our hundreds of markets."
|
description="Discover what's new, trending, or soon-to-close. Or search among our hundreds of markets."
|
||||||
url="/markets"
|
url="/markets"
|
||||||
/>
|
/>
|
||||||
{/* <HotMarkets contracts={hotContracts} />
|
{contracts === undefined ? (
|
||||||
<Spacer h={10} />
|
<LoadingIndicator />
|
||||||
<ClosingSoonMarkets contracts={closingSoonContracts} />
|
) : (
|
||||||
<Spacer h={10} /> */}
|
|
||||||
|
|
||||||
<SearchableGrid contracts={contracts} />
|
<SearchableGrid contracts={contracts} />
|
||||||
|
)}
|
||||||
</Page>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user