fix: modify the color of the username in the preview

This commit is contained in:
codytseng
2025-02-24 22:57:38 +08:00
parent dbe7db7160
commit 3cb24e1f5f
3 changed files with 47 additions and 5 deletions

View File

@@ -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 (
<SimpleUsername
userId={userId}
showAt
className="font-normal inline truncate"
withoutSkeleton
/>
)
}
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 <EmbeddedMention key={`embedded-npub-${index}-${npub1}`} userId={npub1} />
}
}
export const embeddedNostrNpubTextRenderer: TEmbeddedRenderer = {
regex: /(nostr:npub1[a-z0-9]{58})/g,
render: (id: string, index: number) => {
const npub1 = id.split(':')[1]
return <EmbeddedMentionText key={`embedded-nostr-npub-text-${index}-${npub1}`} userId={npub1} />
}
}
export const embeddedNostrProfileTextRenderer: TEmbeddedRenderer = {
regex: /(nostr:nprofile1[a-z0-9]+)/g,
render: (id: string, index: number) => {
const nprofile = id.split(':')[1]
return (
<EmbeddedMentionText
key={`embedded-nostr-profile-text-${index}-${nprofile}`}
userId={nprofile}
/>
)
}
}