Skip to content

Commit

Permalink
Add support for Commento (spf13#74)
Browse files Browse the repository at this point in the history
Add support for Commento
  • Loading branch information
htr3n authored Jun 3, 2019
2 parents 3551425 + 1e04705 commit 2fed57d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ __`Hyde-hyde`__ essentially inherits most of Hyde's [options](https://github.com
* `UtterancesIssueTerm = "pathname"` Method for Utterances to match issue's to posts (pathname, url, title, og:title)
* `UtterancesTheme = "github-light"` Theme for Utterances (github-light, github-dark)

* `Commento = true`: to use [Commento](https://commento.io/) instead of the built-in [Disqus](https://disqus.com). This option should be used exclusively with `disqusShortname = "disqus-shortname"`.
* `CommentoHost = "your-commento-instance"` [Self-hosted Commento](https://docs.commento.io/installation/self-hosting/) instance. This is not required if you're a [Commento.io](https://commento.io) user.

* `[params.social]`: in this section, you can set many social identities such as Twitter, Facebook, Github, Bitbucket, Gitlab, Instagram, LinkedIn, StackOverflow, Medium, Xing, Keybase.

```toml
Expand Down
25 changes: 25 additions & 0 deletions layouts/partials/page-single/comment/commento.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div id="commento"></div>
<script type="text/javascript">
/*
Check and don't inject Commento on localhost/127.0.0.1, however, it does not
work for customised local domains, e.g. example.test, example.dev
*/
(function () {
if (location.hostname === "localhost" ||
location.hostname === "127.0.0.1" ||
location.hostname === "") {
return;
}
var cmt = document.createElement('script');
cmt.type = 'text/javascript';
cmt.async = true;
var commento_host = '{{ with .Site.Params.CommentoHost }}{{ . }}{{else}}https://cdn.commento.io{{ end }}';
cmt.src = commento_host + '/js/commento.js';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(cmt);
})();
</script>

<noscript>
Please enable JavaScript to load the comments.
</noscript>
2 changes: 2 additions & 0 deletions layouts/partials/page-single/post-comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
{{ partial "page-single/comment/graphcomment.html" . }}
{{ else if .Site.Params.UtterancesRepo }}
{{ partial "page-single/comment/utterances.html" . }}
{{ else if .Site.Params.Commento }}
{{ partial "page-single/comment/commento.html" . }}
{{ end }}
{{ end }}

0 comments on commit 2fed57d

Please sign in to comment.