import React, { useState, useEffect } from "react"; import { marked } from 'marked'; export default function TopicDetail(props) { const [showCopied, setShowCopied] = useState(false); if (!props.topic) { return
Topic not found
; } const shareUrl = typeof window !== 'undefined' ? window.location.href : ''; const title = props.topic.title; const text = `Check out this article: ${title}`; // const shareOnFacebook = () => { // window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`, '_blank'); // }; // const shareOnTwitter = () => { // window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}&text=${encodeURIComponent(text)}`, '_blank'); // }; // const shareOnLinkedIn = () => { // window.open(`https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(shareUrl)}&title=${encodeURIComponent(title)}`, '_blank'); // }; // const shareOnReddit = () => { // window.open(`https://www.reddit.com/submit?url=${encodeURIComponent(shareUrl)}&title=${encodeURIComponent(title)}`, '_blank'); // }; // const shareOnWhatsApp = () => { // window.open(`https://wa.me/?text=${encodeURIComponent(`${text} ${shareUrl}`)}`, '_blank'); // }; // const shareViaEmail = () => { // window.open(`mailto:?subject=${encodeURIComponent(title)}&body=${encodeURIComponent(`${text}\n\n${shareUrl}`)}`); // }; const shareOnSocialMedia = (platform) => { switch (platform){ case 'facebook': window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`, '_blank'); break; case 'twitter': window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}&text=${encodeURIComponent(text)}`, '_blank'); break; case 'linkedin': window.open(`https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(shareUrl)}&title=${encodeURIComponent(title)}`, '_blank'); break; case 'reddit': window.open(`https://www.reddit.com/submit?url=${encodeURIComponent(shareUrl)}&title=${encodeURIComponent(title)}`, '_blank'); break; case 'whatsapp': window.open(`https://wa.me/?text=${encodeURIComponent(`${text} ${shareUrl}`)}`, '_blank'); break; case 'email': window.open(`mailto:?subject=${encodeURIComponent(title)}&body=${encodeURIComponent(`${text}\n\n${shareUrl}`)}`); break; } } const copyToClipboard = () => { navigator.clipboard.writeText(shareUrl); setShowCopied(true); setTimeout(() => setShowCopied(false), 2000); }; // SVG Icons with improved styling const SocialIcon = ({ children, className = "" }) => ( {children} ); const FacebookIcon = () => ( ); const TwitterIcon = () => ( ); const LinkedInIcon = () => ( ); const RedditIcon = () => ( ); const WhatsAppIcon = () => ( ); const MailIcon = () => ( ); const LinkIcon = () => ( ); return (
{props.topic.title}

{props.topic.title}

{/* Enhanced Social Share Buttons */}

Share this article:

{showCopied && (
Link copied!
)}
); }