Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utterances #308

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Utterances #308

wants to merge 2 commits into from

Conversation

jklaise
Copy link

@jklaise jklaise commented Oct 6, 2019

Cleaned up #275 . Just integrated this on my own blog, works like a charm!

@jklaise jklaise mentioned this pull request Oct 6, 2019
@jklaise
Copy link
Author

jklaise commented Oct 6, 2019

On second thought the script should probably go in header.html with the rest of the links/stylesheets.

@VincentTam
Copy link
Contributor

On second thought the script should probably go in header.html with the rest of the links/stylesheets.

Why don't load the script for Utterances just like Disqus?

@jklaise
Copy link
Author

jklaise commented Oct 7, 2019

@VincentTam I'm not that familiar with this, the Utterances website shows the script embedded as is (complete with the async parameter). What would need to change to make it load similar to Disqus loading? I'm looking at single.html for Disqus but can't work out what's happening there.

Edit: it looks like Disqus is loaded (delayed) in footer.html?

@VincentTam
Copy link
Contributor

VincentTam commented Oct 8, 2019

@VincentTam I'm not that familiar with this, the Utterances website shows the script embedded as is (complete with the async parameter). What would need to change to make it load similar to Disqus loading? I'm looking at single.html for Disqus but can't work out what's happening there.

Edit: it looks like Disqus is loaded (delayed) in footer.html?

I'm familiar with neither one. I mean to load either one in the same Go-HTML template, like what you've already done.

{{ else }}
<div class="disqus-comments">
{{ template "_internal/disqus.html" . }}
</div>
{{ end }}
{{ end }}
{{ if .Site.Params.staticman }}
<div class="staticman-comments">
{{ partial "staticman-comments.html" . }}
</div>
{{ end }}
{{ if .Site.Params.Utterances }}
<script src="https://utteranc.es/client.js"
repo="{{ .Site.Params.Utterances.repo }}"
issue-term="{{ .Site.Params.Utterances.issue_term }}"
label="{{ .Site.Params.Utterances.label }}"
theme="{{ .Site.Params.Utterances.theme }}"
crossorigin="anonymous"
async>
</script>
{{ end }}

Edit: yes, here's the code.

{{ if and .Site.Params.delayDisqus .Site.DisqusShortname }}
<!-- Delayed Disqus -->
<script type="text/javascript">
$(function(){
$('#show-comments').on('click', function(){
var disqus_shortname = '{{ .Site.DisqusShortname }}';
(function() {
var disqus = document.createElement('script');
disqus.type = 'text/javascript';
disqus.async = true;
disqus.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(disqus);
})();
$(this).hide();
});
});
</script>
<script id="dsq-count-scr" src="//{{ .Site.DisqusShortname }}.disqus.com/count.js" async></script>
<!-- End Delayed Disqus -->
{{ end }}

On second thought the script should probably go in header.html with the rest of the links/stylesheets.

I've just checked the documentation. Your second thought is incorrect because of the following bolded sentence from the docs.

Enable Utterances

Add the following script tag to your blog's template. Position it where you want the comments to appear. Customize the layout using the .utterances and .utterances-frame selectors.

<script src="https://utteranc.es/client.js"
        repo="[ENTER REPO HERE]"
        issue-term="pathname"
        theme="github-light"
        crossorigin="anonymous"
        async>
</script>

@aoyawale
Copy link

is there a similar tool for gitlab?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants