fix(notes): render image preview

This commit is contained in:
en 2025-02-21 14:49:24 +01:00
parent 01ca102dcc
commit 5f33c5e68a
2 changed files with 10 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import { BlogPreview } from './internal/BlogPreview'
import { ModPreview } from './internal/ModPreview'
import { NoteWrapper } from './internal/NoteWrapper'
import { NIP05_REGEX } from 'nostr-tools/nip05'
import { isValidImageUrl, isValidUrl } from 'utils'
interface NoteRenderProps {
content: string
@ -33,6 +34,15 @@ export const NoteRender = ({ content }: NoteRenderProps) => {
const _parts = parts.map((part, index) => {
if (link.test(part)) {
const [href] = part.match(link) || []
if (href && isValidUrl(href)) {
// Image
if (isValidImageUrl(href)) {
return <img className='imgFeedRender' src={href} alt='' />
}
}
// Link
return (
<a key={index} target='_blank' href={href}>
{href}

View File

@ -65,9 +65,6 @@
.IBMSMSMBSSCL_CBText {
white-space: pre-line;
display: flex;
flex-direction: column;
grid-gap: 5px;
}
.IBMSMSMBSSCL_CBTextStatus {