Skip to content

Instantly share code, notes, and snippets.

@mrcave
Last active December 10, 2015 18:49
Show Gist options
  • Save mrcave/4477511 to your computer and use it in GitHub Desktop.
Save mrcave/4477511 to your computer and use it in GitHub Desktop.
The ultimate guide to socializing your LightCMS website http://lightignite.com/the-ultimate-guide-to-socializing-your-lightcms-website
<script type="text/javascript">
// <![CDATA[
var switchTo5x=false;
// ]]>
</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
// <![CDATA[
stLight.options({publisher:'XXX'});
// ]]>
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.share-this-blog-list.js"></script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
$(document).ready(function(){
//Run through the page and find each individual blog post
$(".blogList li").each(function () {
//Grab post title & encode any quotes so they don't mess up generated HTML
var $postTitle = $.trim($(this).children(".postTitle").text().replace(/"/g, """));
//Grab URL from the anchor element inside the h2 element (will not grab correct link in admin mode)
var $postLink = location.protocol + '//' + location.host + $(this).children("h2").find("a[href]").attr('href');
//Add "share this" HTML elements to the bottom of the post
$(this).append(
'<div class="st">' +
'<span class="st_twitter_button" displayText="Tweet" st_url="' + $postLink + '" st_title="' + $postTitle + '"></span>' +
'<span class="st_facebook_button" displayText="Facebook" st_url="' + $postLink + '" st_title="' + $postTitle + '"></span>' +
'</div>'
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment