core/pages/index.tsx
2021-01-29 21:56:20 +09:00

95 lines
3.3 KiB
TypeScript

import { NextPage } from 'next'
import dynamic from 'next/dynamic'
import { BotList } from '@types'
import * as Query from '@utils/Query'
import { categories, categoryIcon } from '@utils/Constants'
const Advertisement = dynamic(()=> import('@components/Advertisement'))
const Container = dynamic(()=> import('@components/Container'))
const BotCard = dynamic(()=> import('@components/BotCard'))
const Wave = dynamic(()=> import('@components/Wave'))
const Tag = dynamic(()=> import('@components/Tag'))
const Search = dynamic(()=> import('@components/Search'))
const Paginator = dynamic(()=> import('@components/Paginator'))
const Index: NextPage<IndexProps> = ({ votes, newBots, trusted }) => {
return (
<>
<div className='dark:bg-discord-black bg-discord-blurple'>
<Container className='pb-24 pt-20' ignoreColor paddingTop>
<h1 className='text-center text-gray-100 text-3xl font-bold sm:text-left'>
</h1>
<Search />
<div className='flex flex-wrap mt-5'>
<Tag key='list' text={<>
<i className='fas fa-heart text-red-600'/>
</>} dark bigger href='/list/votes' />
{ categories.slice(0, 5).map(t=> <Tag key={t} text={<>
<i className={categoryIcon[t]} /> {t}
</>} dark bigger href={`/categories/${t}`} />) }
<Tag key='tag' text={<>
<i className='fas fa-tag'/>
</>} dark bigger href='/categories' />
</div>
</Container>
</div>
<Wave
color='currentColor'
className='dark:text-discord-black text-discord-blurple dark:bg-discord-dark bg-white hidden md:block'
/>
<Container>
<Advertisement />
<h1 className='text-3xl font-bold'>
<i className='far fa-heart mr-3 text-pink-600' />
</h1>
<p className='text-base'> !</p>
<div className='grid gap-4 2xl:grid-cols-4 md:grid-cols-2 mt-10'>
{
votes.data.slice(0, 8).map(bot=> <BotCard key={bot.id} bot={bot} />)
}
</div>
<Paginator totalPage={votes.totalPage} currentPage={votes.currentPage} pathname='/list/votes' />
<h1 className='text-3xl font-bold mt-20'>
<i className='far fa-star mr-3 text-yellow-500' />
</h1>
<p className='text-base'> .</p>
<div className='grid gap-4 2xl:grid-cols-4 md:grid-cols-2 mt-10'>
{
newBots.data.slice(0, 4).map(bot=> <BotCard key={bot.id} bot={bot} />)
}
</div>
<h1 className='text-3xl font-bold'>
<i className='fa fa-check mr-3 mt-10 text-green-500' />
</h1>
<p className='text-base'>KOREANBOTS에서 !!</p>
<div className='grid gap-4 2xl:grid-cols-4 md:grid-cols-2 mt-10'>
{
trusted.data.slice(0, 4).map(bot=> <BotCard key={bot.id} bot={bot} />)
}
</div>
<Advertisement />
</Container>
</>
)
}
export const getServerSideProps = async() => {
const votes = await Query.get.list.votes.load(1)
const newBots = await Query.get.list.new.load(1)
const trusted = await Query.get.list.trusted.load(1)
return { props: { votes, newBots, trusted }}
}
interface IndexProps {
votes: BotList
newBots: BotList
trusted: BotList
}
export default Index