Files
mes-budgets-participatifs/src/components/MarkdownContent.tsx

38 lines
832 B
TypeScript

'use client';
import React from 'react';
import { parseMarkdown } from '@/lib/markdown';
interface MarkdownContentProps {
content: string;
className?: string;
maxLength?: number;
showPreview?: boolean;
}
export function MarkdownContent({
content,
className = "",
maxLength,
showPreview = false
}: MarkdownContentProps) {
if (!content) {
return null;
}
// Si showPreview est activé et qu'une longueur max est définie, tronquer
const displayContent = showPreview && maxLength && content.length > maxLength
? content.substring(0, maxLength) + '...'
: content;
// Parser le markdown
const parsedContent = parseMarkdown(displayContent);
return (
<div
className={`prose prose-sm max-w-none ${className}`}
dangerouslySetInnerHTML={{ __html: parsedContent }}
/>
);
}