diff --git a/src/components/profile/ProfileView.tsx b/src/components/profile/ProfileView.tsx index 1d9e9a8..f5eaba9 100644 --- a/src/components/profile/ProfileView.tsx +++ b/src/components/profile/ProfileView.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { NDKEvent, nip19 } from "@nostr-dev-kit/ndk"; import { useUIStore } from "../../stores/ui"; import { useUserStore } from "../../stores/user"; @@ -12,6 +12,9 @@ import { ArticleCard } from "../article/ArticleCard"; import { ZapModal } from "../zap/ZapModal"; import { ImageLightbox } from "../shared/ImageLightbox"; import { EditProfileForm } from "./EditProfileForm"; +import { parseContent } from "../../lib/parsing"; +import { tryHandleUrlInternally, tryOpenNostrEntity } from "../feed/TextSegments"; +import { openUrl } from "@tauri-apps/plugin-opener"; import { ProfileMediaGallery } from "./ProfileMediaGallery"; function TopFollowerAvatar({ pubkey }: { pubkey: string }) { @@ -88,6 +91,7 @@ export function ProfileView() { const name = profileName(profile, shortenPubkey(pubkey)); const avatar = typeof profile?.picture === "string" ? profile.picture : undefined; const about = typeof profile?.about === "string" ? profile.about : undefined; + const aboutSegments = useMemo(() => about ? parseContent(about) : [], [about]); const nip05 = typeof profile?.nip05 === "string" ? profile.nip05 : undefined; const website = typeof profile?.website === "string" ? profile.website : undefined; const lud16 = typeof profile?.lud16 === "string" ? profile.lud16 : undefined; @@ -255,7 +259,31 @@ export function ProfileView() { {website.replace(/^https?:\/\//, "")} )} - {about &&
{about}
} + {about && ( ++ {aboutSegments.map((seg, i) => { + if (seg.type === "link") return ( + { e.preventDefault(); e.stopPropagation(); if (!tryHandleUrlInternally(seg.value)) openUrl(seg.value).catch(() => {}); }}> + {seg.display || seg.value} + + ); + if (seg.type === "mention" || seg.type === "naddr") return ( + { e.stopPropagation(); tryOpenNostrEntity(seg.value); }}> + {seg.type === "mention" ? "@" : "🔗 "}{String(seg.display ?? seg.value).slice(0, 20)}… + + ); + if (seg.type === "hashtag") return ( + { e.stopPropagation(); useUIStore.getState().openHashtag?.(seg.value); }}> + {String(seg.display ?? seg.value)} + + ); + return {seg.value}; + })} +
+ )} {isOwn && !about && (No bio yet — click "edit profile" to add one.
)}