feat: OG image scraper - auto-fetch recipe images from Pinterest/URLs

- New backend service: og-scraper.service.ts (extracts og:image, og:title, og:description)
- Pinterest support via Twitterbot UA (gets original resolution from i.pinimg.com)
- Works with Chefkoch, Allrecipes, blogs, any site with og:image meta tags
- GET /api/og-preview?url= for preview
- POST /api/recipes/:id/fetch-image to download + process with sharp
- Frontend: 'Bild holen' button appears when source URL is filled
- Auto-fills title & description from OG data if empty
- Images processed to WebP, max 1200px wide
This commit is contained in:
clawd
2026-02-18 10:15:18 +00:00
parent ee452efa6a
commit 60ca01fb94
8 changed files with 216 additions and 10 deletions

View File

@@ -72,3 +72,20 @@ export function uploadRecipeImage(id: string, file: File) {
return r.json() as Promise<{ image_url: string }>
})
}
export interface OgData {
image?: string
title?: string
description?: string
}
export function fetchOgPreview(url: string) {
return apiFetch<OgData>(`/og-preview?url=${encodeURIComponent(url)}`)
}
export function fetchImageFromUrl(recipeId: string, url: string) {
return apiFetch<{ ok: boolean; image_url: string; og_title?: string; og_description?: string }>(
`/recipes/${recipeId}/fetch-image`,
{ method: 'POST', body: JSON.stringify({ url }) }
)
}