diff --git a/src/components/ArticleActions.tsx b/src/components/ArticleActions.tsx index 3b908c8..b88a1b8 100644 --- a/src/components/ArticleActions.tsx +++ b/src/components/ArticleActions.tsx @@ -1,11 +1,11 @@ import { TRPCClientError } from "@trpc/client"; -import { useContext, useEffect, useState, type FC } from "react"; +import { useContext, useEffect, useState, FC } from "react"; import { toast } from "react-toastify"; import { Bookmarkplus, Comment, Dots, Heart, Share } from "~/svgs"; import Bookmarked from "~/svgs/Bookmarked"; import type { Article } from "~/types"; import { api } from "~/utils/api"; -import { C, type ContextValue } from "~/utils/context"; +import { C, ContextValue } from "~/utils/context"; const ArticleActions: FC<{ article: Article; @@ -57,9 +57,27 @@ const ArticleActions: FC<{ } }; + const shareArticle = () => { + if ('share' in navigator) { + navigator.share({ + title: 'Share this article', + text: 'Check out this article', + url: window.location.href, + }) + .then(() => { + console.log('Shared successfully'); + }) + .catch((error) => { + console.error('Error sharing:', error); + }); + } else { + console.error('Web Share API not supported'); + } +}; + return (
-
+