feat: enable inline image rendering in nostr-native blog posts

- Install rehype-raw plugin for HTML support in ReactMarkdown
- Configure ReactMarkdown to parse and render HTML img tags
- Add responsive image styling with max-width and auto height
- Images now render inline in nostr-native blog posts with proper styling
This commit is contained in:
Gigi
2025-10-13 16:34:08 +02:00
parent 8f14f0347c
commit d9fd4ec286
3 changed files with 201 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import React, { useMemo, useState, useEffect } from 'react'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import rehypeRaw from 'rehype-raw'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faSpinner, faCheck } from '@fortawesome/free-solid-svg-icons'
import { RelayPool } from 'applesauce-relay'
@@ -216,7 +217,25 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
{/* Hidden markdown preview to convert markdown to HTML */}
{markdown && (
<div ref={markdownPreviewRef} style={{ display: 'none' }}>
<ReactMarkdown remarkPlugins={[remarkGfm]}>
<ReactMarkdown
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeRaw]}
components={{
img: ({ src, alt, ...props }) => (
<img
src={src}
alt={alt}
{...props}
style={{
maxWidth: '100%',
height: 'auto',
display: 'block',
margin: '1rem auto'
}}
/>
)
}}
>
{processedMarkdown || markdown}
</ReactMarkdown>
</div>