Skip to content

Commit

Permalink
feat: add ability to skip OG image generation during builds (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steen3S authored Nov 22, 2024
1 parent 039822c commit aa5db07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/utils/og.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@ interface OgImageProps {
background: string;
}

const SKIP_OG_IMAGES = process.env.SKIP_OG_IMAGES === 'true';
const base64Image = loadFile('public/assets/images/opengraph-image.jpg');

export const generateOgImage = ({ title, background }: OgImageProps) => {
const width = 1200;
const height = 630;

// If SKIP_OG_IMAGES is true, return a placeholder image instead of generating one dynamically.
// This significantly speeds up builds during emergency patches by skipping resource-intensive OG image generation.
if (SKIP_OG_IMAGES) {
return new Response(base64Image, {
headers: {
'Content-Type': 'image/jpeg',
'Cache-Control': 'public, max-age=31536000, immutable',
},
});
}

const icon = loadDataUrl(`public/assets/images/revoke-icon-orange-black.svg`, 'image/svg+xml');

const response = (
Expand Down
Binary file added public/assets/images/opengraph-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit aa5db07

Please sign in to comment.