<div class="social-share">
<h3>Share This Post</h3>
<a href="https://www.facebook.com/sharer/sharer.php?u=POST_URL" target="_blank" class="facebook">Facebook</a>
<a href="https://twitter.com/intent/tweet?text=POST_TITLE&url=POST_URL" target="_blank" class="twitter">Twitter</a>
<a href="https://www.linkedin.com/sharing/share-offsite/?url=POST_URL" target="_blank" class="linkedin">LinkedIn</a>
<a href="https://pinterest.com/pin/create/button/?url=POST_URL&media=IMAGE_URL&description=POST_TITLE" target="_blank" class="pinterest">Pinterest</a>
</div>
<style>
.social-share a {
display: inline-block;
padding: 8px 15px;
margin: 5px;
color: white;
border-radius: 5px;
text-decoration: none;
}
.facebook { background: #3b5998; }
.twitter { background: #1da1f2; }
.linkedin { background: #0077b5; }
.pinterest { background: #bd081c; }
</style>
<script>
// Automatically replace placeholders with actual post data
document.addEventListener('DOMContentLoaded', function() {
const postUrl = encodeURIComponent(window.location.href);
const postTitle = encodeURIComponent(document.title);
const imageUrl = encodeURIComponent(document.querySelector('.post-body img').src);
document.querySelectorAll('.social-share a').forEach(link => {
link.href = link.href.replace('POST_URL', postUrl)
.replace('POST_TITLE', postTitle)
.replace('IMAGE_URL', imageUrl);
});
});
</script>

No comments:
Post a Comment