Skip to content

Commit

Permalink
Added GitHub and GitHub Enterprise Comment API formats to post.
Browse files Browse the repository at this point in the history
  • Loading branch information
stedman committed Oct 12, 2013
1 parent 7b0a6cf commit 67397e7
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -50,7 +50,7 @@ And here's the snippet of the layout file for generating blog posts (``page.comm
</div>
{% endhighlight %}

Third, add a JavaScript script to each blog posts which pulls the post's comments from the issue using the GitHub API. The [GitHub issues API](http://developer.github.com/v3/issues/) is exactly what we need here - make an <del>JSONP</del> XHR request to the API endpoint and you'll receive all the comments for a specific issue. For each comment you get the GitHub user id and gravatar id of the person who made the comment, the comment id in the issue, created and updated timestamps and the body of the comment. Again, since you're probably using Jekyll, it's easiest if you put the code in the layout file for blog posts. For example, here's the code for pulling in the comments for this blog post, using [jQuery](http://api.jquery.com/jQuery.ajax/) (notice again that you need a Liquid template to specify the URL of the issue for which you want to pull the comments):
Third, add a JavaScript script to each blog posts which pulls the post's comments from the issue using the GitHub API. The [GitHub issues API](http://developer.github.com/v3/issues/) is exactly what we need here - make an <del>JSONP</del> XHR request to the API endpoint (GitHub format: `https://api.github.com/repos/:owner/:repo/issues/:number/comments`; GitHub Enterprise format: `https://:hostname/api/v3/repos/:owner/:repo/issues/:number/comments`) and you'll receive all the comments for a specific issue. For each comment you get the GitHub user id and gravatar id of the person who made the comment, the comment id in the issue, created and updated timestamps and the body of the comment. Again, since you're probably using Jekyll, it's easiest if you put the code in the layout file for blog posts. For example, here's the code for pulling in the comments for this blog post, using [jQuery](http://api.jquery.com/jQuery.ajax/) (notice again that you need a Liquid template to specify the URL of the issue for which you want to pull the comments):

{% highlight html linenos %}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
Expand Down

0 comments on commit 67397e7

Please sign in to comment.