The code and data behind xeiaso.net
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix blogpost sharing button from non-chromium browsers (#733)

Closes #726

authored by

Dym Sohin and committed by
GitHub
a871337a c04d9d6d

+19 -9
+19 -9
lume/src/_includes/blog.njk
··· 43 43 title: document.title, 44 44 url: window.location.href 45 45 }; 46 - if (!navigator.canShare(shareData)) { 47 - console.log("can't share"); 48 - return; 46 + if (navigator.share && navigator.canShare(shareData)) { 47 + // console.log("(via navigator.share)"); 48 + navigator 49 + .share(shareData) 50 + .then(() => { 51 + console.log("Thanks for sharing!"); 52 + }) 53 + .catch(console.error); 54 + } 55 + else if (navigator.clipboard) { 56 + // console.log("(via navigator.clipboard)"); 57 + navigator.clipboard.writeText(shareData.url) 58 + .then(() => { 59 + console.log("Thanks for sharing!"); 60 + }) 61 + .catch(console.error); 49 62 } 50 - navigator 51 - .share({title: document.title, url: window.location.href}) 52 - .then(() => { 53 - console.log('Thanks for sharing!'); 54 - }) 55 - .catch(console.error); 63 + else { 64 + console.log("can't share directly, but feel free to copy the url from addressbar manually"); 65 + } 56 66 } 57 67 shareButton.addEventListener("click", doShareButton); 58 68 </script>