mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-11-18 09:37:30 +01:00
refactor: improve opengraph image generation with better fallback handling
- Add `revalidate = false` to disable revalidation for static images - Refactor iconUrl to be null when icon not found, using placeholder only in img src - This provides cleaner separation between data and presentation logic
This commit is contained in:
@@ -4,6 +4,8 @@ import { ImageResponse } from "next/og"
|
||||
import { getAllIcons } from "@/lib/api"
|
||||
|
||||
export const dynamic = "force-static"
|
||||
export const revalidate = false
|
||||
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const iconsData = await getAllIcons()
|
||||
@@ -72,7 +74,7 @@ export default async function Image({ params }: { params: Promise<{ icon: string
|
||||
// Convert the image data to a data URL or use placeholder
|
||||
const iconUrl = iconData
|
||||
? `data:image/png;base64,${iconData.toString("base64")}`
|
||||
: `https://placehold.co/600x400?text=${formattedIconName}`
|
||||
: null
|
||||
|
||||
return new ImageResponse(
|
||||
<div
|
||||
@@ -157,7 +159,7 @@ export default async function Image({ params }: { params: Promise<{ icon: string
|
||||
}}
|
||||
/>
|
||||
<img
|
||||
src={iconUrl}
|
||||
src={iconUrl || `https://placehold.co/600x400?text=${formattedIconName}`}
|
||||
alt={formattedIconName}
|
||||
width={260}
|
||||
height={260}
|
||||
|
||||
Reference in New Issue
Block a user