import { motion } from 'framer-motion' import { useEffect, useState } from 'react' import { cn } from 'ui' import { Markdown } from '@/components/interfaces/Markdown' const CHAR_LIMIT = 500 // Adjust this number as needed export const MarkdownContent = ({ integrationId, initiallyExpanded, }: { integrationId: string initiallyExpanded?: boolean }) => { const [content, setContent] = useState('') const [isExpanded, setIsExpanded] = useState(initiallyExpanded ?? false) useEffect(() => { import(`@/static-data/integrations/${integrationId}/overview.md`) .then((module) => setContent(String(module.default))) .catch((error) => console.error('Error loading markdown:', error)) }, [integrationId]) const displayContent = isExpanded ? content : content.slice(0, CHAR_LIMIT) const supportExpanding = content.length > CHAR_LIMIT || (content.match(/\n/g) || []).length > 1 if (displayContent.length === 0) return null return (
{!isExpanded && (
)} {supportExpanding && (
)}
) }