diff --git a/app/utils/resolve-og-image.ts b/app/utils/resolve-og-image.ts new file mode 100644 index 0000000..d2e7e17 --- /dev/null +++ b/app/utils/resolve-og-image.ts @@ -0,0 +1,14 @@ +/** + * Resolves an article's og:image to an absolute URL. + * Strategy (D-05): frontmatter `image` if present, else branded fallback `/og-blog-default.jpg`. + * Consumed by: app/pages/blog/[slug].vue (useSeoMeta.ogImage + defineArticle.image) + * app/pages/blog/index.vue (useSeoMeta.ogImage fallback only). + */ +const SITE_URL = 'https://killiandalcin.fr' +const FALLBACK = '/og-blog-default.jpg' + +export function resolveOgImage(article?: { image?: string } | null): string { + const raw = article?.image?.trim() || FALLBACK + if (raw.startsWith('http://') || raw.startsWith('https://')) return raw + return `${SITE_URL}${raw.startsWith('/') ? raw : `/${raw}`}` +} diff --git a/public/og-blog-default.jpg b/public/og-blog-default.jpg new file mode 100644 index 0000000..fd256f9 --- /dev/null +++ b/public/og-blog-default.jpg @@ -0,0 +1 @@ +PLACEHOLDER: Replace with actual 1200x630 og:image for killiandalcin.fr