Last active
August 29, 2015 14:11
-
-
Save rwz/58c73746f539c9ea28df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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