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 "@ssr/common/utils/scoresaber-utils"; import { StarIcon } from "../../components/star-icon"; import { GlobeIcon } from "../../components/globe-icon"; import NodeCache from "node-cache"; import ScoreSaberPlayerToken from "@ssr/common/types/token/scoresaber/score-saber-player-token"; import ScoreSaberLeaderboardToken from "@ssr/common/types/token/scoresaber/score-saber-leaderboard-token"; const cache = new NodeCache({ stdTTL: 60 * 60, // 1 hour checkperiod: 120, }); export class ImageService { /** * The base of the OpenGraph image * * @param children the content of the image * @private */ public static BaseImage({ children }: { children: React.ReactNode }) { return (
{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}