Skip to content

Commit b9a562d

Browse files
npes87184daattali
authored andcommitted
add fb comment (daattali#350)
* add fb comment * Update README.md for facebook comments * Update _config.yml * Update README.md
1 parent 786849a commit b9a562d

5 files changed

Lines changed: 30 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ Many personalization settings in `_config.yml`, such as setting your name and si
104104

105105
### Allowing users to leave comments
106106

107-
If you want to enable comments on your site, Beautiful Jekyll supports the [Disqus](https://disqus.com/) comments plugin. To use it, simply sign up to Disqus and add your Disqus shortname to the `disqus` parameter in the `_config.yml`.
107+
If you want to enable comments on your site, Beautiful Jekyll supports either the [Disqus](https://disqus.com/) comments plugin or [Facebook](https://developers.facebook.com/docs/plugins/comments) comments.
108108

109-
If the `disqus` parameter is set in the configuration file, then all blog posts will have comments turned on by default. To turn off comments on a particular blog post, add `comments: false` to the YAML front matter. If you want to add comments on the bottom of a non-blog page, add `comments: true` to the YAML front matter.
109+
To use Disqus, simply sign up to [Disqus](https://disqus.com/) and add your Disqus shortname to the `disqus` parameter in the `_config.yml` file.
110+
111+
To use Facebook comments, create a Facebook app using [Facebook developers](https://developers.facebook.com/docs/apps/register), and add the Facebook App ID to the `fb_comment_id` parameter in `_config.yml`.
112+
113+
If either `disqus` or `fb_comment_id` parameters are set in the configuration file, then all blog posts will have comments turned on by default. To turn off comments on a particular blog post, add `comments: false` to the YAML front matter. If you want to add comments on the bottom of a non-blog page, add `comments: true` to the YAML front matter.
110114

111115
### Adding Google Analytics to track page views
112116

_config.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,15 @@ url-pretty: "MyWebsite.com" # eg. "deanattali.com/beautiful-jekyll"
118118
# uri: "demo.wiki.pro"
119119
# opt-out: true
120120

121-
# --- Misc --- #
121+
# --- Comments --- #
122+
122123
# Fill in your Disqus shortname (NOT the userid) if you want to support Disqus comments
123-
#disqus: ""
124+
# disqus: ""
125+
126+
# To use Facebook Comments, fill in a Facebook App ID
127+
# fb_comment_id: ""
128+
129+
# --- Misc --- #
124130

125131
# Facebook App ID
126132
# fb_app_id: ""

_includes/fb-comment.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{%- if site.fb_comment_id -%}
2+
<div class="comments">
3+
<div id="fb-root"></div>
4+
<script>(function(d, s, id) {
5+
var js, fjs = d.getElementsByTagName(s)[0];
6+
if (d.getElementById(id)) return;
7+
js = d.createElement(s); js.id = id;
8+
js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.12&appId={{ site.fb_comment_id }}&autoLogAppEvents=1';
9+
fjs.parentNode.insertBefore(js, fjs);
10+
}(document, 'script', 'facebook-jssdk'));</script>
11+
<div class="fb-comments" data-href="{{ site.url }}{{ page.url }}" data-width="100%" data-numposts="5"></div>
12+
<noscript>Please enable JavaScript to view the comments powered by Facebook.</noscript>
13+
</div>
14+
{%- endif -%}

_layouts/page.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<div class="disqus-comments">
1313
{% include disqus.html %}
1414
</div>
15+
{% include fb-comment.html %}
1516
{% endif %}
1617
</div>
1718
</div>

_layouts/post.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<div class="disqus-comments">
7070
{% include disqus.html %}
7171
</div>
72+
{% include fb-comment.html %}
7273
{% endif %}
7374
</div>
7475
</div>

0 commit comments

Comments
 (0)