Files
eranos/src/lib/getDisplayName.ts
T
Alex Gleason be7cfbab67 Render NIP-30 custom emoji in display names, post text, and bios
Add emojify/EmojifiedText utilities that replace :shortcode: patterns with
inline images using emoji tags from kind 0 and kind 1 events. Applied to
display names across NoteCard, PostDetailPage, ProfilePage, ProfileHoverCard,
InteractionsModal, NotificationsPage, and NoteContent @mentions. Also
emojifies about/bio text in ProfilePage and ProfileHoverCard.

Remove string-level truncation from getDisplayName to avoid breaking
shortcodes mid-pattern (CSS truncate handles visual overflow). Use
em-relative sizing and align-text-bottom for proper inline alignment.
2026-02-19 19:06:14 -06:00

16 lines
519 B
TypeScript

import { genUserName } from '@/lib/genUserName';
import type { NostrMetadata } from '@nostrify/nostrify';
/**
* Get a display name for a user.
* Uses metadata.name if available, otherwise generates a deterministic username.
* Visual truncation is handled by CSS (`truncate` class) on the containing element
* to avoid breaking NIP-30 custom emoji shortcodes.
*/
export function getDisplayName(
metadata: NostrMetadata | undefined,
pubkey: string,
): string {
return metadata?.name || genUserName(pubkey);
}