From ccc4df6a550cc918e6d9f979b093eae0cf945d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9B=90=EB=8D=94?= Date: Mon, 8 Feb 2021 22:39:47 +0900 Subject: [PATCH] feat: using makeBotURL function --- components/BotCard.tsx | 6 ++---- utils/Tools.ts | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/BotCard.tsx b/components/BotCard.tsx index d0bb153..2ce426c 100644 --- a/components/BotCard.tsx +++ b/components/BotCard.tsx @@ -1,5 +1,5 @@ import { Bot } from '../types' -import { formatNumber } from '@utils/Tools' +import { formatNumber, makeBotURL } from '@utils/Tools' import { Status } from '@utils/Constants' import Divider from './Divider' import Tag from './Tag' @@ -50,9 +50,7 @@ const BotCard = ({ bot }: BotProps): JSX.Element => {
보기 diff --git a/utils/Tools.ts b/utils/Tools.ts index 282efc4..d78686f 100644 --- a/utils/Tools.ts +++ b/utils/Tools.ts @@ -2,7 +2,7 @@ import { Readable } from 'stream' import { NextPageContext } from 'next' import cookie from 'cookie' -import { ImageOptions, UserPemissionFlags } from '@types' +import { Bot, ImageOptions, UserPemissionFlags } from '@types' import { KoreanbotsEndPoints, Oauth, perms } from './Constants' import { NextRouter } from 'next/router' @@ -27,6 +27,9 @@ export function makeImageURL(root:string, { format='png', size=256 }:ImageOption return `${root}.${format}?size=${size}` } +export function makeBotURL(bot: Bot): string { + return `/bots/${(bot.partnered || bot.trusted) && bot.vanity ? bot.vanity : bot.id}` +} export function supportsWebP() { const elem = document.createElement('canvas') if (elem.getContext && elem.getContext('2d')) {