feat: using makeBotURL function

This commit is contained in:
원더 2021-02-08 22:39:47 +09:00
parent 12dda17c0a
commit ccc4df6a55
2 changed files with 6 additions and 5 deletions

View File

@ -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 => {
<Divider />
<div className='flex justify-evenly'>
<Link
href={`/bots/${
(bot.partnered || bot.trusted) && bot.vanity ? bot.vanity : bot.id
}`}
href={makeBotURL(bot)}
>
<a className='rounded-bl-2xl py-3 w-full text-center text-koreanbots-blue hover:text-white text-sm font-bold hover:bg-koreanbots-blue hover:shadow-lg transition duration-100 ease-in'>

View File

@ -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')) {