This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/gitgram/web/components/RichEmbeds.tsx
caelum0x bfc29616b7 feat: round-7 external harvest (18 features, all products green)
- gitgram-web (4): external link-preview/unfurl cards, rich inline embed players
  (YouTube/Twitch/Spotify/Vimeo)
- gitgram-backend (1): natural-language feed filtering (preferredLangOnly) + Post.contentLanguage
- gitgram-mobile (4): notification grouping/aggregation, shared timeAgo util
- aitm-api (7): GitNexus graph-RAG query + context retrieval endpoints (flagship surface)
- aitm-mcp (2): beads_claim atomic claim-for-work tool + brief-deps projection

Note: gitgram-backend adds Post.contentLanguage — run prisma migrate at deploy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 19:17:27 +03:00

44 lines
1.4 KiB
TypeScript

'use client'
import { useMemo } from 'react'
import { extractUrls } from '@/utils/extractUrls'
import { getEmbedPlayerSource } from '@/utils/embedPlayer'
import EmbedPlayer from './EmbedPlayer'
import LinkCard from './LinkCard'
interface RichEmbedsProps {
/** Raw post content to scan for embeddable / unfurlable URLs. */
content: string
/** Maximum number of embeds to render below the text (default 2). */
max?: number
className?: string
}
/**
* Scans post content for external URLs and renders, for each:
* - an inline media player (YouTube/Twitch/Spotify/Vimeo/SoundCloud/Apple
* Music/Giphy) when the URL maps to a known provider, or
* - a link-preview / unfurl card (title, description, image, domain) for any
* other external URL.
*
* Renders nothing when the content has no external URLs, so it is safe to mount
* unconditionally after any post body.
*/
export default function RichEmbeds({ content, max = 2, className = '' }: RichEmbedsProps) {
const urls = useMemo(() => extractUrls(content, { limit: max }), [content, max])
if (urls.length === 0) return null
return (
<div className={`mt-3 flex flex-col gap-3 ${className}`}>
{urls.map((url) => {
const player = getEmbedPlayerSource(url)
if (player) {
return <EmbedPlayer key={url} params={player} url={url} />
}
return <LinkCard key={url} url={url} />
})}
</div>
)
}