feat : big update
This commit is contained in:
@@ -3,6 +3,7 @@ import { ImageResponse } from "next/og";
|
||||
import sharp from "sharp";
|
||||
|
||||
import { rarityGradient } from "@/lib/catalog/rarity";
|
||||
import { imageContentDisposition } from "@/lib/guides/export-image";
|
||||
import { getPublicTeamExport } from "@/lib/guides/queries";
|
||||
|
||||
const anuphanFonts = Promise.all(
|
||||
@@ -29,19 +30,6 @@ function amount(value: number): string {
|
||||
return new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(value);
|
||||
}
|
||||
|
||||
function contentDisposition(teamName: string): string {
|
||||
const displayName = teamName.trim() || "team";
|
||||
const fallback = displayName
|
||||
.normalize("NFKD")
|
||||
.replace(/[^a-z0-9]+/giu, "-")
|
||||
.replace(/^-|-$/gu, "") || "team";
|
||||
const encoded = encodeURIComponent(`${displayName}.png`).replace(
|
||||
/['()*]/gu,
|
||||
(character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`,
|
||||
);
|
||||
return `attachment; filename="${fallback}.png"; filename*=UTF-8''${encoded}`;
|
||||
}
|
||||
|
||||
async function pngDataUrl(url: string): Promise<string | null> {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
@@ -186,7 +174,7 @@ export async function GET(
|
||||
fonts: fonts.length ? fonts : undefined,
|
||||
headers: {
|
||||
"Cache-Control": "no-store",
|
||||
"Content-Disposition": contentDisposition(team.title),
|
||||
"Content-Disposition": imageContentDisposition(team.title, "team"),
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user