Skip to content

Commit

Permalink
New feature Disqus comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jhauraw committed May 27, 2020
1 parent b62475c commit c0e02aa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions layouts/_default/single.html
Expand Up @@ -33,6 +33,7 @@ <h1 class="post-title font-content-title font-normal leading-tight tracking-defa
{{- .Content }}
</article>
{{ partial "adsense" . }}
{{ partial "disqus" . }}
</div>
</div>
</div>
Expand Down
20 changes: 20 additions & 0 deletions layouts/partials/disqus.html
@@ -0,0 +1,20 @@
{{- if and .Site.Params.services.disqusShortname (not (eq .Params.comments false)) }}
<div id="disqus_thread" class="mt-12"></div>
<script>
var disqus_config = function () {
this.page.url = {{ .Permalink }};
this.page.identifier = {{ .File.UniqueID }};
this.page.title = {{ .Title }};
};

(function() {
window.setTimeout(function() {
var d = document, s = d.createElement('script');
s.src = 'https://{{ .Site.Params.services.disqusShortname }}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
s.setAttribute("defer", "");
d.body.appendChild(s);
}, 2500);
})();
</script>
{{- end }}
20 changes: 10 additions & 10 deletions layouts/partials/scripts-foot.html
Expand Up @@ -14,10 +14,10 @@
<script>
(function() {
window.setTimeout(function() {
var gAds = document.createElement("script");
gAds.setAttribute("defer", "defer");
gAds.src = {{ $adsbygoogle }};
document.body.appendChild(gAds);
var d = document, ads = d.createElement('script');
ads.src = {{ $adsbygoogle }};
ads.setAttribute("defer", "");
d.body.appendChild(ads);
}, 2000);
})();
</script>
Expand All @@ -30,12 +30,12 @@
<script>
(function() {
window.setTimeout(function(){
var fbPixel = document.createElement("img");
fbPixel.setAttribute("width", "1");
fbPixel.setAttribute("height", "1");
fbPixel.setAttribute("style", "display:none");
fbPixel.src = "https://www.facebook.com/tr?id={{ . }}&amp;ev=PageView";
document.body.appendChild(fbPixel);
var d = document, fb = d.createElement("img");
fb.src = "https://www.facebook.com/tr?id={{ . }}&amp;ev=PageView";
fb.setAttribute("width", "1");
fb.setAttribute("height", "1");
fb.setAttribute("style", "display:none");
d.body.appendChild(fb);
}, 1750);
})();
</script>
Expand Down

0 comments on commit c0e02aa

Please sign in to comment.