diff --git a/src/components/ContentPreview/index.tsx b/src/components/ContentPreview/index.tsx index a1d38201..4f03ce0b 100644 --- a/src/components/ContentPreview/index.tsx +++ b/src/components/ContentPreview/index.tsx @@ -3,7 +3,11 @@ import { cn } from '@/lib/utils' import { Event } from 'nostr-tools' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' -import { embedded, embeddedNostrNpubRenderer, embeddedNostrProfileRenderer } from '../Embedded' +import { + embedded, + embeddedNostrNpubTextRenderer, + embeddedNostrProfileTextRenderer +} from '../Embedded' export default function ContentPreview({ event, @@ -26,7 +30,10 @@ export default function ContentPreview({ if (embeddedNotes.length) { contents.push(`[${t('note')}]`) } - return embedded(contents.join(' '), [embeddedNostrProfileRenderer, embeddedNostrNpubRenderer]) + return embedded(contents.join(' '), [ + embeddedNostrProfileTextRenderer, + embeddedNostrNpubTextRenderer + ]) }, [event]) if (!event) return null diff --git a/src/components/Embedded/EmbeddedMention.tsx b/src/components/Embedded/EmbeddedMention.tsx index 483496f4..ded95fe5 100644 --- a/src/components/Embedded/EmbeddedMention.tsx +++ b/src/components/Embedded/EmbeddedMention.tsx @@ -1,4 +1,4 @@ -import Username from '../Username' +import Username, { SimpleUsername } from '../Username' import { TEmbeddedRenderer } from './types' export function EmbeddedMention({ userId }: { userId: string }) { @@ -12,6 +12,17 @@ export function EmbeddedMention({ userId }: { userId: string }) { ) } +export function EmbeddedMentionText({ userId }: { userId: string }) { + return ( + + ) +} + export const embeddedNostrNpubRenderer: TEmbeddedRenderer = { regex: /(nostr:npub1[a-z0-9]{58})/g, render: (id: string, index: number) => { @@ -34,3 +45,24 @@ export const embeddedNpubRenderer: TEmbeddedRenderer = { return } } + +export const embeddedNostrNpubTextRenderer: TEmbeddedRenderer = { + regex: /(nostr:npub1[a-z0-9]{58})/g, + render: (id: string, index: number) => { + const npub1 = id.split(':')[1] + return + } +} + +export const embeddedNostrProfileTextRenderer: TEmbeddedRenderer = { + regex: /(nostr:nprofile1[a-z0-9]+)/g, + render: (id: string, index: number) => { + const nprofile = id.split(':')[1] + return ( + + ) + } +} diff --git a/src/components/Username/index.tsx b/src/components/Username/index.tsx index 88c3ddc3..918ca7d6 100644 --- a/src/components/Username/index.tsx +++ b/src/components/Username/index.tsx @@ -56,21 +56,24 @@ export function SimpleUsername({ userId, showAt = false, className, - skeletonClassName + skeletonClassName, + withoutSkeleton = false }: { userId: string showAt?: boolean className?: string skeletonClassName?: string + withoutSkeleton?: boolean }) { const { profile } = useFetchProfile(userId) - if (!profile) { + if (!profile && !withoutSkeleton) { return (
) } + if (!profile) return null const { username } = profile