diff --git a/src/routes/post/[slug]/+page.server.ts b/src/routes/post/[slug]/+page.server.ts index 40a1666..e2baa12 100644 --- a/src/routes/post/[slug]/+page.server.ts +++ b/src/routes/post/[slug]/+page.server.ts @@ -171,6 +171,43 @@ export const load: PageServerLoad = async ({ params, locals, url, setHeaders }) }; jsonLd.push(articleLd); + // Collect YouTube embeds from row*Content and emit a VideoObject per video. + // Helps Google index the post as a video page (rich result eligibility). + type RowItem = { _type?: string; youtubeId?: string; title?: string; description?: string }; + const rows: RowItem[] = [ + ...(((post as { row1Content?: RowItem[] }).row1Content) ?? []), + ...(((post as { row2Content?: RowItem[] }).row2Content) ?? []), + ...(((post as { row3Content?: RowItem[] }).row3Content) ?? []), + ]; + const videos = rows.filter( + (r) => r && r._type === 'youtube_video' && typeof r.youtubeId === 'string' && r.youtubeId, + ); + for (const v of videos) { + const id = v.youtubeId as string; + jsonLd.push({ + '@context': 'https://schema.org', + '@type': 'VideoObject', + name: v.title ?? postHeadline, + description: v.description ?? postDescription ?? postHeadline, + thumbnailUrl: [ + `https://i.ytimg.com/vi/${id}/maxresdefault.jpg`, + `https://i.ytimg.com/vi/${id}/hqdefault.jpg`, + ], + uploadDate: postCreated ?? new Date().toISOString(), + contentUrl: `https://www.youtube.com/watch?v=${id}`, + embedUrl: `https://www.youtube.com/embed/${id}`, + ...(siteBaseUrl + ? { + publisher: { + '@type': 'Organization', + name: siteName, + url: siteBaseUrl, + }, + } + : {}), + }); + } + if (isEvent && eventDateRaw) { const eventLd: Record = { '@context': 'https://schema.org',