manifold/web/pages/index.tsx

55 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-12-03 01:18:00 +00:00
import React from 'react'
import _ from 'lodash'
2022-01-05 06:32:52 +00:00
import {
Contract,
getHotContracts,
listAllContracts,
} from '../lib/firebase/contracts'
import { ContractsGrid } from '../components/contracts-list'
import { Spacer } from '../components/layout/spacer'
import { Page } from '../components/page'
import { Title } from '../components/title'
import { ActivityFeed } from './activity'
import { getRecentComments, Comment } from '../lib/firebase/comments'
2021-12-19 05:59:34 +00:00
export async function getStaticProps() {
const [contracts, hotContracts, recentComments] = await Promise.all([
2022-01-05 06:32:52 +00:00
listAllContracts().catch((_) => []),
getHotContracts().catch(() => []),
getRecentComments().catch(() => []),
2022-01-05 06:32:52 +00:00
])
2021-12-19 05:59:34 +00:00
return {
props: {
contracts,
hotContracts,
recentComments,
2021-12-19 05:59:34 +00:00
},
revalidate: 60, // regenerate after a minute
}
}
const Home = (props: {
contracts: Contract[]
hotContracts: Contract[]
recentComments: Comment[]
}) => {
const { contracts, hotContracts, recentComments } = props
return (
<Page>
<div className="w-full bg-indigo-50 border-2 border-indigo-100 p-6 rounded-lg shadow-md">
<Title className="mt-0" text="🔥 Markets" />
<ContractsGrid contracts={hotContracts} showHotVolume />
</div>
<Spacer h={10} />
2022-01-08 06:23:50 +00:00
<ActivityFeed contracts={contracts} recentComments={recentComments} />
</Page>
2022-01-05 06:32:52 +00:00
)
}
export default Home