Improve social media OG/Twitter meta for posts
Deploy / verify (push) Successful in 51s
Deploy / deploy (push) Successful in 1m2s

- Fix bug: post page was overriding og:image with 150x200 thumbnail
- og:type = "article" for posts (was always "website")
- article:published_time, article:modified_time, article:author, article:tag
- og:image:alt + twitter:image:alt (post headline)
- twitter:label1/data1 with reading time
- Remove thumbnail fallback from socialImage (falls back to site logo instead)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Peter Meier
2026-05-16 15:35:32 +02:00
parent d7a84aff0d
commit 44b991f7c1
3 changed files with 43 additions and 13 deletions
+12 -3
View File
@@ -303,13 +303,22 @@ export const load: PageServerLoad = async ({ params, locals, url, setHeaders })
translations,
seoTitle: post.seoTitle ?? postHeadline,
seoDescription: postDescription,
socialImage: postSocialImageAbs ?? postImageUrl ?? undefined,
socialImage: postSocialImageAbs ?? undefined,
ogType: 'article' as const,
ogImageAlt: postHeadline,
articlePublishedTime: postCreated,
articleModifiedTime: postUpdated,
articleAuthor: postAuthor ?? siteName,
articleTags: (() => {
const tags = (post as { postTag?: Array<{ name?: string }> }).postTag ?? [];
return tags.map((t) => (typeof t === 'string' ? t : (t?.name ?? ''))).filter(Boolean);
})(),
twitterLabel1: 'Lesezeit',
twitterData1: `${readingTimeMinutes} Min.`,
robots: (post as { seoMetaRobots?: string }).seoMetaRobots ?? undefined,
keywords: (() => {
const explicit = ((post as { seoKeywords?: string }).seoKeywords ?? '').trim();
if (explicit) return explicit;
// Fallback: join tag names so published posts without explicit keywords
// still ship a meaningful <meta name="keywords">.
const tags = (post as { postTag?: Array<{ name?: string }> }).postTag ?? [];
const names = tags
.map((t) => (typeof t?.name === 'string' ? t.name.trim() : ''))
-9
View File
@@ -14,15 +14,6 @@
let { data }: { data: PageData } = $props();
</script>
<svelte:head>
<title>{data.seoTitle}</title>
{#if data.seoDescription}
<meta name="description" content={data.seoDescription} />
{/if}
{#if data.postImageUrl}
<meta property="og:image" content={data.postImageUrl} />
{/if}
</svelte:head>
<div class="my-4 md:flex md:items-start md:gap-4">
{#if data.rawPostImageUrl}