"use client"; import { useState } from "react"; import { siX, siLinkedin, siWhatsapp } from "simple-icons"; type ShareBarProps = { text: string; // texte du tweet/post }; export function ShareBar({ text }: ShareBarProps) { const [copied, setCopied] = useState(false); const url = "https://wikirush.xyz"; const encoded = encodeURIComponent(text + "\n" + url); const links = [ { label: "X", href: `https://x.com/intent/tweet?text=${encoded}`, si: siX, }, { label: "LinkedIn", href: `https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(url)}&title=${encodeURIComponent("WikiRush")}&summary=${encodeURIComponent(text)}`, si: siLinkedin, }, { label: "WhatsApp", href: `https://wa.me/?text=${encoded}`, si: siWhatsapp, }, ]; function copyToClipboard() { navigator.clipboard.writeText(text + "\n" + url).then(() => { setCopied(true); setTimeout(() => setCopied(false), 2000); }); } return (
Partager
{links.map(({ label, href, si }) => ( {label} ))}
); }