import { Badge } from '@/components/ui/badge' import { useFetchRelayInfo } from '@/hooks' import { normalizeHttpUrl } from '@/lib/url' import { GitBranch, Mail, SquareCode } from 'lucide-react' import { useTranslation } from 'react-i18next' import RelayBadges from '../RelayBadges' import RelayIcon from '../RelayIcon' import UserAvatar from '../UserAvatar' import Username from '../Username' export default function RelayInfo({ url }: { url: string }) { const { t } = useTranslation() const { relayInfo, isFetching } = useFetchRelayInfo(url) if (isFetching || !relayInfo) { return null } return (
{relayInfo.name || relayInfo.shortUrl}
{!!relayInfo.tags?.length && (
{relayInfo.tags.map((tag) => ( {tag} ))}
)} {relayInfo.description && (
{relayInfo.description}
)}
{!!relayInfo.supported_nips?.length && (
{t('Supported NIPs')}
{relayInfo.supported_nips .sort((a, b) => a - b) .map((nip) => ( window.open( `https://github.com/nostr-protocol/nips/blob/master/${formatNip(nip)}.md` ) } > {formatNip(nip)} ))}
)} {relayInfo.payments_url && (
{t('Payment page')}:
{relayInfo.payments_url}
)}
{relayInfo.pubkey && (
{t('Operator')}
)} {relayInfo.contact && (
{t('Contact')}
{relayInfo.contact}
)} {relayInfo.software && (
{t('Software')}
{formatSoftware(relayInfo.software)}
)} {relayInfo.version && (
{t('Version')}
{relayInfo.version}
)}
) } function formatSoftware(software: string) { const parts = software.split('/') return parts[parts.length - 1] } function formatNip(nip: number) { if (nip < 10) { return `0${nip}` } return `${nip}` }