core/pages/servers/index.tsx
2024-10-13 01:16:31 +09:00

64 lines
2.0 KiB
TypeScript

import { NextPage } from 'next'
import dynamic from 'next/dynamic'
import { Server, List } from '@types'
import * as Query from '@utils/Query'
const Advertisement = dynamic(() => import('@components/Advertisement'))
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
const Container = dynamic(() => import('@components/Container'))
const ServerCard = dynamic(() => import('@components/ServerCard'))
const Paginator = dynamic(() => import('@components/Paginator'))
const Hero = dynamic(() => import('@components/Hero'))
const ServerIndex: NextPage<ServerIndexProps> = ({ votes, trusted }) => {
return (
<>
<Hero type='servers' />
<Container className='pb-10'>
<Advertisement />
<h1 className='mb-2 mt-10 text-3xl font-bold'>
<i className='far fa-heart mr-3 text-pink-600' />
</h1>
<p className='text-base'> !</p>
<ResponsiveGrid>
{votes.data.map((server) => (
<ServerCard type='list' key={server.id} server={server} />
))}
</ResponsiveGrid>
<Paginator
totalPage={votes.totalPage}
currentPage={votes.currentPage}
pathname='/servers/list/votes'
/>
<Advertisement />
<h1 className='mb-2 text-3xl font-bold'>
<i className='fa fa-check mr-3 mt-10 text-emerald-500' />
</h1>
<p className='text-base'> !!</p>
<ResponsiveGrid>
{trusted.data.slice(0, 4).map((server) => (
<ServerCard type='list' key={server.id} server={server} />
))}
</ResponsiveGrid>
<Advertisement />
</Container>
</>
)
}
export const getStaticProps = async () => {
const votes = await Query.get.serverList.votes.load(1)
const trusted = await Query.get.serverList.trusted.load(1)
return { props: { votes, trusted }, revalidate: 60 }
}
interface ServerIndexProps {
votes: List<Server>
newBots: List<Server>
trusted: List<Server>
}
export default ServerIndex