From fae410243b7ecf1d9b3b45b7be3a528a8ff56164 Mon Sep 17 00:00:00 2001 From: kayjaydee Date: Wed, 22 Apr 2026 11:16:37 +0200 Subject: [PATCH] feat(07-02): add resolveOgImage helper + og-blog-default.jpg fallback asset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - app/utils/resolve-og-image.ts: absolutises frontmatter image or falls back to /og-blog-default.jpg - public/og-blog-default.jpg: placeholder (copied from og-image.png) — branded 1200x630 design follow-up pending --- app/utils/resolve-og-image.ts | 14 ++++++++++++++ public/og-blog-default.jpg | 1 + 2 files changed, 15 insertions(+) create mode 100644 app/utils/resolve-og-image.ts create mode 100644 public/og-blog-default.jpg 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