Skip to content

Commit 40715dc

Browse files
committed
copy to clipboard done
1 parent 1b8c1fa commit 40715dc

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/components/socialshare.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ const SocialShare = ({ id, description, islightcolor }) => {
4040

4141
const url = `${site.siteMetadata.siteUrl}/${id}`
4242
const urlLength = String(url).length
43+
44+
const handleCopy = () => {
45+
if (typeof navigator !== "undefined") {
46+
navigator.clipboard.writeText(url).then(() => {
47+
console.log("Copied!", url)
48+
})
49+
}
50+
}
51+
4352
return (
4453
<SocialShareContainer islightcolor={islightcolor}>
4554
<h4>শেয়ার করুন</h4>
@@ -67,15 +76,7 @@ const SocialShare = ({ id, description, islightcolor }) => {
6776
</a>
6877
</li>
6978
<li>
70-
<a
71-
onClick={() =>
72-
console.log(
73-
`Copy ${site.siteMetadata.siteUrl}/${id} to the clipboard`
74-
)
75-
}
76-
>
77-
Link
78-
</a>
79+
<a onClick={handleCopy}>Link</a>
7980
</li>
8081
</ul>
8182
</SocialShareContainer>

0 commit comments

Comments
 (0)