mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 14:10:22 +00:00
feat: add trusted bots page (#649)
* feat: add trusted bots page * feat: add button for trusted bots * chore: reduce trusted bot count to 4
This commit is contained in:
parent
d736370287
commit
5532d17b5f
@ -42,6 +42,11 @@ const Index: NextPage<IndexProps> = ({ votes, newBots, trusted }) => {
|
||||
<BotCard key={bot.id} bot={bot} />
|
||||
))}
|
||||
</ResponsiveGrid>
|
||||
{trusted.data.length > 4 && (
|
||||
<LongButton href='/bots/list/trusted' center>
|
||||
더보기
|
||||
</LongButton>
|
||||
)}
|
||||
<h1 className='mb-2 mt-20 text-3xl font-bold'>
|
||||
<i className='far fa-star mr-3 text-amber-500' /> 새로운 봇
|
||||
</h1>
|
||||
|
||||
68
pages/bots/list/trusted.tsx
Normal file
68
pages/bots/list/trusted.tsx
Normal file
@ -0,0 +1,68 @@
|
||||
import { NextPage, NextPageContext } from 'next'
|
||||
import dynamic from 'next/dynamic'
|
||||
|
||||
import { get } from '@utils/Query'
|
||||
import { Bot, List } from '@types'
|
||||
import { ParsedUrlQuery } from 'querystring'
|
||||
import { PageCount } from '@utils/Yup'
|
||||
|
||||
const Hero = dynamic(() => import('@components/Hero'))
|
||||
const Advertisement = dynamic(() => import('@components/Advertisement'))
|
||||
const BotCard = dynamic(() => import('@components/BotCard'))
|
||||
const Container = dynamic(() => import('@components/Container'))
|
||||
const ResponsiveGrid = dynamic(() => import('@components/ResponsiveGrid'))
|
||||
|
||||
const Trusted: NextPage<TrustedProps> = ({ data }) => {
|
||||
return (
|
||||
<>
|
||||
<Hero
|
||||
type='bots'
|
||||
header='신뢰된 봇'
|
||||
description='한국 디스코드 리스트에서 엄격한 기준을 통과한 봇들입니다!'
|
||||
/>
|
||||
<Container className='pb-10'>
|
||||
<Advertisement />
|
||||
<ResponsiveGrid>
|
||||
{data.data.map((bot) => (
|
||||
<BotCard key={bot.id} bot={bot} />
|
||||
))}
|
||||
</ResponsiveGrid>
|
||||
{/* <Paginator
|
||||
totalPage={data.totalPage}
|
||||
currentPage={data.currentPage}
|
||||
pathname='/bots/list/trusted'
|
||||
/> */}
|
||||
<Advertisement />
|
||||
</Container>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export const getServerSideProps = async (ctx: Context) => {
|
||||
let data: List<Bot>
|
||||
if (!ctx.query.page) ctx.query.page = '1'
|
||||
const validate = await PageCount.validate(ctx.query.page)
|
||||
.then((el) => el)
|
||||
.catch(() => null)
|
||||
if (!validate || isNaN(Number(ctx.query.page))) data = null
|
||||
else data = await get.list.trusted.load(Number(ctx.query.page))
|
||||
return {
|
||||
props: {
|
||||
data,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
interface Context extends NextPageContext {
|
||||
query: URLQuery
|
||||
}
|
||||
|
||||
interface URLQuery extends ParsedUrlQuery {
|
||||
page: string
|
||||
}
|
||||
|
||||
interface TrustedProps {
|
||||
data: List<Bot>
|
||||
}
|
||||
|
||||
export default Trusted
|
||||
Loading…
x
Reference in New Issue
Block a user