Hardcode in 8 frontpage markets

This commit is contained in:
Austin Chen 2022-05-07 19:44:01 -04:00
parent cea9422802
commit 2eed1c432a
3 changed files with 19 additions and 3 deletions

View File

@ -46,7 +46,7 @@ export function FeedPromo(props: { hotContracts: Contract[] }) {
<Row className="m-4 mb-6 items-center gap-1 text-xl font-semibold text-gray-800">
<SparklesIcon className="inline h-5 w-5" aria-hidden="true" />
Trending today
Trending markets
</Row>
<ContractsGrid
contracts={hotContracts?.slice(0, 10) || []}

View File

@ -239,6 +239,13 @@ export async function getHotContracts() {
)
}
export async function getContractsBySlugs(slugs: string[]) {
const q = query(contractCollection, where('slug', 'in', slugs))
const snapshot = await getDocs(q)
const contracts = snapshot.docs.map((doc) => doc.data() as Contract)
return _.sortBy(contracts, (contract) => -1 * contract.volume24Hours)
}
const topWeeklyQuery = query(
contractCollection,
where('isResolved', '==', false),

View File

@ -1,7 +1,7 @@
import React from 'react'
import Router from 'next/router'
import { Contract, getHotContracts } from '../lib/firebase/contracts'
import { Contract, getContractsBySlugs } from '../lib/firebase/contracts'
import { Page } from '../components/page'
import { FeedPromo } from '../components/feed-create'
import { Col } from '../components/layout/col'
@ -9,7 +9,16 @@ import { useUser } from '../hooks/use-user'
import { ManifoldLogo } from '../components/nav/manifold-logo'
export async function getStaticProps() {
const hotContracts = (await getHotContracts().catch(() => [])) ?? []
const hotContracts = await getContractsBySlugs([
'if-boris-johnson-is-leader-of-the-c',
'will-ethereum-merge-to-proofofstake',
'will-russia-control-the-majority-of',
'will-elon-musk-buy-twitter-this-yea',
'will-an-ai-get-gold-on-any-internat',
'how-many-us-supreme-court-justices',
'who-will-win-the-nba-finals-champio',
'what-database-will-manifold-be-prim',
])
return {
props: { hotContracts },