Skip to content

Instantly share code, notes, and snippets.

@aintai
Created February 1, 2022 08:42
Show Gist options
  • Save aintai/bf1c8da96ab1c46be13b7ba89e8e1a9d to your computer and use it in GitHub Desktop.
Save aintai/bf1c8da96ab1c46be13b7ba89e8e1a9d to your computer and use it in GitHub Desktop.
tagcloud for Tumblr
<script type="text/javascript">
(function () {
var posts = new TumblrPosts({
domain: "hoge.tumblr.com",
maxNum: 1000 //タグを取得する投稿数(記事数膨大なときの制限用)
});
posts.bind(posts.EVENT_COMPLETE, function (e) {
var that = this;
var tagMaxNum = 50; //表示するタグ数の最大値
$.each(this.getTags("desc"), function (i, tag) {
var html = '<li>' + '<a href="/tagged/' + tag.name + '">' + tag.name + ' (' + tag.count + ')</a></li>';
if (i === tagMaxNum) {return false;}
$(html).appendTo($("ul#tags"));
});
});
posts.run();
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment