From ac6b579afd404c702845605e8272fb1450ebca46 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 12 Jul 2021 19:16:40 +0300 Subject: [PATCH] add sharing buttons --- src/components/Chapter.js | 20 +++++++++++++++++++- src/pages/TableOfContentsPage.js | 18 +++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/components/Chapter.js b/src/components/Chapter.js index d3c8b63..e3205f0 100644 --- a/src/components/Chapter.js +++ b/src/components/Chapter.js @@ -11,11 +11,29 @@ import TableOfContents from "./TableOfContents"; import Footer from "./Footer"; const Chapter = ({ children: chapter }) => { + console.log(chapter) const Content = chapter.content; + function handleShare() { + if (!navigator.share) { + // should be impossible + alert("Sorry, Sharing links are not supported on your device.", chapter.path); + return; + } + navigator.share && navigator.share({ + title: chapter.frontMatter.title + " | LingDocs Pashto Grammar", + url: "https://grammar.lingdocs.com" + chapter.path, + }); + } return <>
-

{chapter.frontMatter.title}

+
+

{chapter.frontMatter.title}

+ {navigator.share &&
+ +
} +
+