-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArticleShare.tsx
54 lines (51 loc) · 2.14 KB
/
ArticleShare.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import Image from "next/image";
import styles from "./ArticleShare.module.scss";
import twitterLogo from "public/twitter_logo.png";
import { ExternalLink } from "~/components/ExternalLink";
import facebookLogo from "public/facebook_logo.png";
import hatenabookmarkLogo from "public/hatenabookmark_logo.png";
import linkIcon from "public/link_icon.svg";
import { ArticleContent } from "~/libs/microcms";
import { siteName, siteUrl } from "~/libs/const";
import { ClipboardButton } from "~/components/ClipboardButton";
type Props = {
article: ArticleContent;
displayMessage?: boolean;
};
export const ArticleShare = ({ article, displayMessage }: Props) => {
const url = `${siteUrl}/pages/${article.id}`;
const title = `${article.title} - ${siteName}`;
return (
<div className={styles.root}>
{displayMessage && <div className={styles.title}>共有お願いします!</div>}
<div className={styles.elementRoot}>
<ExternalLink
aria-label="X(旧Twitter)にポスト"
href={`https://twitter.com/intent/tweet?url=${url}&text=${encodeURIComponent(title)}`}
className={styles.element}
>
<Image src={twitterLogo} alt="X(旧Twitter)" width={24} className={styles.icon} />
</ExternalLink>
<ExternalLink
aria-label="Facebookに投稿"
href={`http://www.facebook.com/sharer.php?u=${url}`}
className={styles.element}
>
<Image src={facebookLogo} alt="Facebook" width={24} className={styles.icon} />
</ExternalLink>
<ExternalLink
aria-label="はてなブックマークに登録"
href={`https://b.hatena.ne.jp/add?mode=confirm&url=${url}&title=${encodeURIComponent(title)}`}
className={styles.element}
>
<Image src={hatenabookmarkLogo} alt="はてなブックマーク" width={24} className={styles.icon} />
</ExternalLink>
<div className={styles.element}>
<ClipboardButton content={`${title}\n${url}\n`}>
<Image src={linkIcon} alt="リンク" width={24} className={styles.icon} />
</ClipboardButton>
</div>
</div>
</div>
);
};