2022-03-24 16:52:13 +00:00
|
|
|
import { GetServerSideProps } from 'next'
|
2022-04-27 17:40:02 +00:00
|
|
|
import { getServerSideSitemap, ISitemapField } from 'next-sitemap'
|
|
|
|
|
2022-08-22 16:52:05 +00:00
|
|
|
import { listAllContracts } from 'web/lib/firebase/contracts'
|
2022-03-24 16:52:13 +00:00
|
|
|
|
|
|
|
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
2022-08-22 19:23:43 +00:00
|
|
|
const contracts = await listAllContracts(1000, undefined, 'popularityScore')
|
2022-03-24 16:52:13 +00:00
|
|
|
|
2022-08-22 16:52:05 +00:00
|
|
|
const score = (popularity: number) => Math.tanh(Math.log10(popularity + 1))
|
2022-04-27 17:40:02 +00:00
|
|
|
|
2022-08-22 17:07:05 +00:00
|
|
|
const fields = contracts
|
|
|
|
.sort((x) => x.popularityScore ?? 0)
|
|
|
|
.map((market) => ({
|
|
|
|
loc: `https://manifold.markets/${market.creatorUsername}/${market.slug}`,
|
|
|
|
changefreq: market.volume24Hours > 10 ? 'hourly' : 'daily',
|
|
|
|
priority: score(market.popularityScore ?? 0),
|
|
|
|
lastmod: market.lastUpdatedTime,
|
|
|
|
})) as ISitemapField[]
|
2022-04-27 17:40:02 +00:00
|
|
|
|
|
|
|
return await getServerSideSitemap(ctx, fields)
|
2022-03-24 16:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Default export to prevent next.js errors
|
|
|
|
export default function Sitemap() {}
|