You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This project automatically generates Open Graph images for blog posts based on their content. It creates custom images for social media sharing and caches them for improved performance.
How It Works
Image Generation API
The/api/createblog endpoint handles POST requests with blog post data.
It passes the data to the/api/generate endpoint to generate an image.
It uses thecanvas library to create an image with the blog's title, description, and author.
If a custom image is provided, it's used as a background with an overlay gradient.
The generated image is saved as a PNG file on vercel blob storage and the url is returned.
The/api/createblog endpoint also creates a blog entry in the database.
Metadata Generation
ThegenerateMetadata function fetches the blog data from the database.
If an Open Graph image URL is present, it returns metadata including the URL.
Image Caching
Generated images are saved on vercel blob storage, avoiding regeneration on subsequent requests.
Blog Post Display
The blog post page displays the content along with the generated Open Graph image.
Key Features
Dynamic image generation based on blog post content
Gradient overlays for background images
Text wrapping for titles and descriptions
Fallback to default styling if no custom image is provided
Caching of generated images for improved performance
Integration with Next.js metadata API for SEO optimization