Add support for Commento (#74)

Add support for Commento
This commit is contained in:
Huy Tran 2019-06-03 10:03:43 +10:00 committed by GitHub
commit 2fed57d3c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 0 deletions

View file

@ -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

View file

@ -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>

View file

@ -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 }}