diff --git a/app/api/og/repository/[owner]/[repository]/route.js b/app/api/og/repository/[owner]/[repository]/route.js index 4d47c5e1b..33bcffa8f 100644 --- a/app/api/og/repository/[owner]/[repository]/route.js +++ b/app/api/og/repository/[owner]/[repository]/route.js @@ -1,8 +1,11 @@ +/* eslint-disable complexity */ + import { GetOGImage } from "lib/graphql"; import { redirect } from "next/navigation"; import { ImageResponse } from "next/og"; export const runtime = "edge"; +export const contentType = "image/png"; export async function GET(request, { params }) { const start = Date.now(); @@ -42,6 +45,8 @@ export async function GET(request, { params }) { const fontBold = await fetch(new URL("/public/fonts/Geist-Black.otf", import.meta.url)).then((res) => res.arrayBuffer()); const fontRegular = await fetch(new URL("/public/fonts/Geist-Regular.otf", import.meta.url)).then((res) => res.arrayBuffer()); + const mostUsedLanguage = og.languages && og.languages.length > 0 ? og.languages.reduce((a, b) => (a.size > b.size ? a : b)) : { node: { name: "Unknown", color: "#c1c1c1" }, size: 0 }; + /* eslint-disable @next/next/no-img-element */ return new ImageResponse( ( @@ -99,25 +104,40 @@ export async function GET(request, { params }) {
+ {mostUsedLanguage.node.name} {Math.floor((mostUsedLanguage.size / og.languages.reduce((a, b) => a + b.size, 0)) * 100) + "%"} +
+ )}