diff --git a/web/src/app/community/[icon]/opengraph-image.tsx b/web/src/app/community/[icon]/opengraph-image.tsx index 61da7c4c..3b922545 100644 --- a/web/src/app/community/[icon]/opengraph-image.tsx +++ b/web/src/app/community/[icon]/opengraph-image.tsx @@ -2,21 +2,9 @@ import { permanentRedirect, redirect } from "next/navigation" import { ImageResponse } from "next/og" import { getCommunityGalleryRecord, getCommunitySubmissionByName, getCommunitySubmissions } from "@/lib/community" +export const runtime = "edge"; export const revalidate = 21600 // 6 hours -export async function generateStaticParams() { - const icons = await getCommunitySubmissions() - const validIcons = icons.filter((icon) => icon.name) - if (process.env.CI_MODE === "false") { - return validIcons.slice(0, 5).map((icon) => ({ - icon: icon.name, - })) - } - return validIcons.map((icon) => ({ - icon: icon.name, - })) -} - export const size = { width: 1200, height: 630, diff --git a/web/src/app/icons/[icon]/opengraph-image.tsx b/web/src/app/icons/[icon]/opengraph-image.tsx index e490b39d..742e6f46 100644 --- a/web/src/app/icons/[icon]/opengraph-image.tsx +++ b/web/src/app/icons/[icon]/opengraph-image.tsx @@ -1,34 +1,23 @@ -import { readFile } from "node:fs/promises" -import { join } from "node:path" -import { ImageResponse } from "next/og" -import { getAllIcons } from "@/lib/api" +import { ImageResponse } from "next/og"; +import { BASE_URL } from "@/constants"; +import { getAllIcons } from "@/lib/api"; -export const revalidate = false - -export async function generateStaticParams() { - const iconsData = await getAllIcons() - if (process.env.CI_MODE === "false") { - // This is meant to speed up the build process in local development - return Object.keys(iconsData) - .slice(0, 5) - .map((icon) => ({ - icon, - })) - } - return Object.keys(iconsData).map((icon) => ({ - icon, - })) -} +export const runtime = "edge"; +export const revalidate = false; export const size = { width: 1200, height: 630, -} -export default async function Image({ params }: { params: Promise<{ icon: string }> }) { - const { icon } = await params +}; +export default async function Image({ + params, +}: { + params: Promise<{ icon: string }>; +}) { + const { icon } = await params; if (!icon) { - console.error(`[Opengraph Image] Icon not found for ${icon}`) + console.error(`[Opengraph Image] Icon not found for ${icon}`); return new ImageResponse(