hermes-agent/apps/desktop/src/components/assistant-ui/embeds/providers/twitter.ts
Brooklyn Nicholson 81ac562bf0 feat(desktop): inline embed detection + module primitives
Pure, synchronous URL→descriptor matchers for YouTube, Vimeo, Instagram,
Pinterest, TikTok, X, Spotify, Google Maps and OpenStreetMap, plus the shared
embed primitives (error boundary, fail card, escape-html, dark-mode hook,
sizing token). Declares the mermaid + dompurify deps used by the fenced
renderers.
2026-06-26 03:21:59 -05:00

27 lines
611 B
TypeScript

import { bareHost, type EmbedMatcher } from './types'
export const twitter: EmbedMatcher = url => {
const host = bareHost(url.hostname)
if (host !== 'twitter.com' && host !== 'x.com') {
return null
}
const segments = url.pathname.split('/').filter(Boolean)
const statusIndex = segments.indexOf('status')
const id = statusIndex >= 0 ? segments[statusIndex + 1] : ''
if (!/^\d+$/.test(id || '')) {
return null
}
return {
id: `twitter:${id}`,
label: 'X',
maxWidth: 480,
provider: 'twitter',
renderer: 'tweet',
sourceUrl: url.toString(),
tweetId: id
}
}