rajoute le support de l'utilisation de markdown (sur un sous-ensemble) dans la description des campagnes et des propositions
This commit is contained in:
37
src/components/MarkdownContent.tsx
Normal file
37
src/components/MarkdownContent.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
'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 }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user