import React from 'react' import { FacebookSVG, LinkedInSVG, TwitterSVG } from './svgIcons' type ShareButtonsProps = { postId: string articleUrl: string title: string } const ShareButtons: React.FC = ({ postId, articleUrl, title, }) => { const shareUrl = articleUrl ? new URL(articleUrl) : null if (shareUrl) { shareUrl.hash = `post-${postId}` } const shareUrlStr: string = shareUrl?.toString() ?? '' const twitterUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent( shareUrlStr )}&text=${encodeURIComponent(title)}&via=ft` const facebookUrl = `http://www.facebook.com/sharer.php?u=${encodeURIComponent( shareUrlStr )}&t=${encodeURIComponent(title)}` const linkedInUrl = `http://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent( shareUrlStr )}&title=${encodeURIComponent(title)}&source=Financial+Times` return (
) } export default ShareButtons