import { ImageResponse } from "@vercel/og"; import { scoresaberService } from "@ssr/common/service/impl/scoresaber"; import React from "react"; import { formatNumberWithCommas, formatPp } from "@ssr/common/utils/number-utils"; import { getDifficultyFromScoreSaberDifficulty } from "website/src/common/scoresaber-utils"; export class ImageService { /** * Generates the OpenGraph image for the player * * @param id the player's id */ public static async generatePlayerImage(id: string) { const player = await scoresaberService.lookupPlayer(id); if (player == undefined) { return undefined; } return new ImageResponse( (
{player.name}
{formatPp(player.pp)}pp
#{formatNumberWithCommas(player.rank)}
#{formatNumberWithCommas(player.countryRank)}
{leaderboard.songName} {leaderboard.songSubName}
{leaderboard.stars}
{getDifficultyFromScoreSaberDifficulty(leaderboard.difficulty.difficulty)}
Mapped by {leaderboard.levelAuthorName}