diff --git a/src/components/code/TalkCard.astro b/src/components/code/TalkCard.astro new file mode 100644 index 0000000..94210ca --- /dev/null +++ b/src/components/code/TalkCard.astro @@ -0,0 +1,68 @@ +--- +import type { Locale } from '../../utils/i18n'; + +interface Props { + title: string; + description: string; + event?: string; + dateFormatted?: string; + location?: string; + video?: string; + tags?: string[]; + copresenters?: { name: string; url: string }[]; + lang?: Locale; +} + +const { title, description, event, dateFormatted, location, video, tags, copresenters, lang = 'fr' } = Astro.props; + +const copresenterLabel = { fr: 'Co-présenté avec', en: 'Co-presented with', ar: 'محاضرة مشتركة مع' }[lang]; + +function getYouTubeId(url: string): string | null { + const match = url.match(/(?:youtu\.be\/|youtube\.com\/watch\?v=)([^&]+)/); + return match?.[1] ?? null; +} + +const videoId = video ? getYouTubeId(video) : null; +--- + +
+ {(event || dateFormatted || location) && ( +
+ {[event, dateFormatted, location].filter(Boolean).join(' · ')} +
+ )} +

{title}

+

{description}

+ {copresenters && copresenters.length > 0 && ( +

+ {copresenterLabel}{' '} + {copresenters.map((cp, i) => ( + <> + {i > 0 && ', '} + {cp.name} + + ))} +

+ )} + + {tags && tags.length > 0 && ( +
+ {tags.map((tag) => ( + + {tag} + + ))} +
+ )} + + {videoId && ( +