From 5532d17b5f992da105595326e3029aefb36c7018 Mon Sep 17 00:00:00 2001 From: SKINMAKER Date: Sun, 7 Jul 2024 21:02:02 +0900 Subject: [PATCH] feat: add trusted bots page (#649) * feat: add trusted bots page * feat: add button for trusted bots * chore: reduce trusted bot count to 4 --- pages/bots/index.tsx | 5 +++ pages/bots/list/trusted.tsx | 68 +++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 pages/bots/list/trusted.tsx diff --git a/pages/bots/index.tsx b/pages/bots/index.tsx index eb429ed..55519be 100644 --- a/pages/bots/index.tsx +++ b/pages/bots/index.tsx @@ -42,6 +42,11 @@ const Index: NextPage = ({ votes, newBots, trusted }) => { ))} + {trusted.data.length > 4 && ( + + 더보기 + + )}

새로운 봇

diff --git a/pages/bots/list/trusted.tsx b/pages/bots/list/trusted.tsx new file mode 100644 index 0000000..b533c4a --- /dev/null +++ b/pages/bots/list/trusted.tsx @@ -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 = ({ data }) => { + return ( + <> + + + + + {data.data.map((bot) => ( + + ))} + + {/* */} + + + + ) +} + +export const getServerSideProps = async (ctx: Context) => { + let data: List + 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 +} + +export default Trusted