Adding comment count links
Closed this issue · 1 comments
I tried to apply this to your module by adding some code to one of your methods:
` DisqusComponent.prototype.addDisqusScript = function () {
/** Set DISQUS config */
this.dService.window.disqus_config = this.getConfig();
/** Add DISQUS script */
var disqusScript = this.renderer.createElement('script');
disqusScript.src = "//" + this.dService.shortname + ".disqus.com/embed.js;
disqusScript.async = true;
disqusScript.type = 'text/javascript';
//New code for comment count:
var disqusCounterScript = this.renderer.createElement('script');
disqusCounterScript.src = "//" + this.dService.shortname + ".disqus.com/count.js";
disqusCounterScript.async = true;
disqusCounterScript.id = 'dsq-count-scr';
disqusCounterScript.type = 'text/javascript';
this.renderer.setAttribute(disqusScript, 'data-timestamp', new Date().getTime().toString());
//append new Script
this.renderer.appendChild(this.el.nativeElement, disqusScript, disqusCounterScript);
};
Then I want to add it to a page which iterates through the commented content:
<a href='"http://www.test.de/" + {{test.id}} + "/"' data-disqus-identifier='{{test.id}}'>First article</a>
But I get the following error message:
Error: Template parse errors: Can't bind to 'disqus-identifier' since it isn't a known property of 'a'.
Do you have a suggestions for how to implement comment count with your module?
I'm not sure how you can do that, I tried to add comments count before, but I couldn't get it to work.
You can get the comments' count using a direct jsonp request.
this.jsonp.request(`https://${this.shortname}.disqus.com/count-data.js?identifier=${ this.identifier }`)
.subscribe((res => console.log(res))
Unfortunately, this is not covered in Disqus Docs, and I can't remember the name of the identifier parameter ?identifier=$
that should be used, but you will probably find out if you research on google.