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:
@@ -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 }) }
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user