Added share buttons

This commit is contained in:
Marcus Noble
2017-10-15 17:31:16 +01:00
parent 296d24a8a2
commit bd38076041
3 changed files with 46 additions and 1 deletions

View File

@@ -9,7 +9,7 @@
<a href="/" class="back-to-blog" title="Return to all posts"></a>
<h2 class="post-title" itemprop="name headline">
<a class="post-link" href="{{ path }}">{{ title }}</a>
<a class="post-link" href="{{ path }}">{{ title }}</a> {{> share }}
</h2>
<div class="post-meta feather_type">
@@ -25,6 +25,9 @@
</div>
</article>
<div class="center">
{{> share shareText='Share this post'}}
</div>
</section>
{{> footer }}
@@ -52,5 +55,19 @@
}
</script>
<script>
if (navigator.share) {
[...document.querySelectorAll('.share')].forEach(function(shareButton) {
shareButton.classList.add('show');
shareButton.addEventListener('click', function(event) {
event.preventDefault();
navigator.share({
title: document.title,
url: window.location.url
});
});
});
}
</script>
</body>
</html>