/** * Universal content component that uses the content parser service * for all Nostr content fields */ import { useEventFieldParser } from '@/hooks/useContentParser' import { Event } from 'nostr-tools' import ImageWithLightbox from '../ImageWithLightbox' import WebPreview from '../WebPreview' import HighlightSourcePreview from './HighlightSourcePreview' interface ParsedContentProps { event: Event field: 'content' | 'title' | 'summary' | 'description' className?: string enableMath?: boolean enableSyntaxHighlighting?: boolean showMedia?: boolean showLinks?: boolean showHashtags?: boolean showNostrLinks?: boolean showHighlightSources?: boolean } export default function ParsedContent({ event, field, className = '', enableMath = true, enableSyntaxHighlighting = true, showMedia = true, showLinks = false, showHashtags = false, showNostrLinks = false, showHighlightSources = false, }: ParsedContentProps) { const { parsedContent, isLoading, error } = useEventFieldParser(event, field, { enableMath, enableSyntaxHighlighting }) if (isLoading) { return (
) } if (error) { return (
Error loading content: {error.message}
) } if (!parsedContent) { return (
No content available
) } return (
{/* Render AsciiDoc content (everything is now processed as AsciiDoc) */}
{/* Media thumbnails */} {showMedia && parsedContent.media.length > 0 && (

Images in this content:

{parsedContent.media.map((media, index) => (
))}
)} {/* Links summary with OpenGraph previews */} {showLinks && parsedContent.links.length > 0 && (

Links in this content:

{parsedContent.links.map((link, index) => ( ))}
)} {/* Hashtags */} {showHashtags && parsedContent.hashtags.length > 0 && (
{parsedContent.hashtags.map((tag) => (
#{tag}
))}
)} {/* Nostr links summary */} {showNostrLinks && parsedContent.nostrLinks.length > 0 && (

Nostr references:

{parsedContent.nostrLinks.map((link, index) => (
{link.type}:{' '} {link.id}
))}
)} {/* Highlight sources */} {showHighlightSources && parsedContent.highlightSources.length > 0 && (

Highlight sources:

{parsedContent.highlightSources.map((source, index) => ( ))}
)}
) }