Skip to content

Instantly share code, notes, and snippets.

@rwz
Last active August 29, 2015 14:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwz/58c73746f539c9ea28df to your computer and use it in GitHub Desktop.
Save rwz/58c73746f539c9ea28df to your computer and use it in GitHub Desktop.
// look ma, no jquery
// assuming that you have
// <a data-komments-permalink="/foobar">comments count goes here</a>
// somewhere in your HTML
function _kmtsLoaded(){
var links = [].slice.apply(document.querySelectorAll("a[data-komments-permalink]"));
links.forEach(function(link){
var permalink = link.getAttribute("data-komments-permalink");
_kmts.api.getEndpointData(permalink, { callback: function(payload){
var count = payload["comments_count"];
link.innerText = count == 1 ? "1 Comment" : count + " Comments";
}});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment