auto-claude: subtask-1-11 - Extract VideoJsonLd component

This commit is contained in:
2026-01-25 11:16:48 +01:00
parent de447b2f59
commit 52aaa5c80c
2 changed files with 61 additions and 3 deletions
@@ -0,0 +1,58 @@
import { type Locale } from '@/i18n/config';
// VideoObject Schema for embedded videos
interface VideoJsonLdProps {
name: string;
description: string;
thumbnailUrl: string;
uploadDate: string;
duration?: string; // ISO 8601 format, e.g., "PT1M30S"
contentUrl?: string;
embedUrl?: string;
locale: Locale;
}
export function VideoJsonLd({
name,
description,
thumbnailUrl,
uploadDate,
duration,
contentUrl,
embedUrl,
locale,
}: VideoJsonLdProps) {
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://damjan-savic.com';
const schema: Record<string, unknown> = {
'@context': 'https://schema.org',
'@type': 'VideoObject',
name: name,
description: description,
thumbnailUrl: thumbnailUrl.startsWith('http') ? thumbnailUrl : `${baseUrl}${thumbnailUrl}`,
uploadDate: uploadDate,
inLanguage: locale === 'de' ? 'de-DE' : locale === 'sr' ? 'sr-RS' : 'en-US',
author: {
'@id': `${baseUrl}/#person`,
},
};
if (duration) {
schema.duration = duration;
}
if (contentUrl) {
schema.contentUrl = contentUrl;
}
if (embedUrl) {
schema.embedUrl = embedUrl;
}
return (
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
/>
);
}